Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dddr

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dddr

  • 2.6.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Alt text

DDDr: Domain Driven Design Repository

Overview

"DDDr" is a Ruby gem designed to simplify the implementation of data repositories in a Domain-Driven Design (DDD) architecture. It provides a clean, easy-to-use interface for abstracting data access, so you can focus on domain logic rather than database operations.

Features

  • Easy-to-use Entity and Repository classes
  • Built-in UUID generation for entities
  • In-memory storage using SDBM
  • Date and time tracking for entities
  • CRUD operation support
  • Extensible query and association methods

Installation

To install, add the gem to your application's @Gemfile@:

gem 'dddr'

Then run:

bundle install

Alternatively, you can install the gem manually:

gem install dddr

Usage

Creating an Entity

Include the @Dddr::Entity@ module in your class:

class MyEntity
  include Dddr::Entity
  attr_accessor :name, :email
end

Using the Repository

repository = MyEntity::Repository.new
entity = MyEntity.new
entity.name = "John Doe"
entity.email = "john.doe@example.com"

# Adding the entity
uid = repository.add(entity)

# Updating the entity
entity.name = "Jane Doe"
updated_entity = repository.update(entity)

# Deleting the entity
repository.delete(entity)

# Fetching an entity by UID
fetched_entity = repository.get(uid)

Custom Queries

Define custom queries using the @queries@ method within your entity class.

class MyEntity
  include Dddr::Entity
  attr_accessor :name, :email

  queries do
    def find_by_email(email)
      # Custom query logic here
    end
  end
end

You can then execute the custom query like this:

repository = MyEntity::Repository.new
repository.find_by_email("john.doe@example.com")

FAQs

Package last updated on 23 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc