Sha256: a6cbd007aef0baea473e33eab0d1d7f26cc1fad5971d10132e0cd15818031714

Contents?: true

Size: 1.77 KB

Versions: 98

Compression:

Stored size: 1.77 KB

Contents

![Alt text](hero.png)

# 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@:

<pre>
gem 'dddr'
</pre>

Then run:

<pre>
bundle install
</pre>

Alternatively, you can install the gem manually:

<pre>
gem install dddr
</pre>

## Usage

### Creating an Entity

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

<pre>
class MyEntity
  include Dddr::Entity
  attr_accessor :name, :email
end
</pre>

### Using the Repository

<pre>
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)
</pre>

### Custom Queries

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

<pre>
class MyEntity
  include Dddr::Entity
  attr_accessor :name, :email

  queries do
    def find_by_email(email)
      # Custom query logic here
    end
  end
end
</pre>

You can then execute the custom query like this:

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

Version data entries

98 entries across 95 versions & 2 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/dddr-1.0.8/README.md
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/dddr-1.0.4/README.md
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/dddr-1.1.0/README.md
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/dddr-1.1.1/README.md
dddr-2.6.0 README.md
dddr-2.5.0 README.md
dddr-2.4.0 README.md
dddr-2.3.0 README.md
dddr-2.2.0 README.md
dddr-2.1.0 README.md
dddr-2.0.3 README.md
dddr-2.0.2 README.md
dddr-2.0.1 README.md
dddr-2.0.0 README.md
dddr-1.1.4 README.md
dddr-1.1.3 README.md
dddr-1.1.2 README.md
dddr-1.1.1 README.md
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/dddr-1.0.4/README.md
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/dddr-1.0.4/README.md