Class: Hecks::Adapters::SQLDatabase::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(module_name:) ⇒ Repository

Returns a new instance of Repository.



5
6
7
8
# File 'lib/repository.rb', line 5

def initialize(module_name:)
  @module_name = module_name
  @head = DOMAIN[module_name].head
end

Instance Method Details

#create(attributes) ⇒ Object



10
11
12
# File 'lib/repository.rb', line 10

def create attributes
  Commands::Create.new(attributes: attributes, head: @head).call
end

#delete(id) ⇒ Object



26
27
28
# File 'lib/repository.rb', line 26

def delete id
  Commands::Delete.new(id: id, head: @head).call
end

#read(id) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/repository.rb', line 18

def read id
  Commands::Read.new(
    id: id,
    head: @head,
    entity_class: entity_class
  ).call
end

#update(id, attributes) ⇒ Object



14
15
16
# File 'lib/repository.rb', line 14

def update id, attributes
  Commands::Update.new(id: id, attributes: attributes, head: @head).call
end