Class: HecksAdapters::SQLDatabase::Repository
- Inherits:
-
Object
- Object
- HecksAdapters::SQLDatabase::Repository
- Defined in:
- lib/repository.rb
Overview
Translates calls from an application into SQL Commands
Instance Method Summary collapse
- #create(attributes) ⇒ Object
- #delete(id) ⇒ Object
-
#initialize(module_name:) ⇒ Repository
constructor
A new instance of Repository.
- #read(id) ⇒ Object
- #update(id, attributes) ⇒ Object
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
22 23 24 |
# File 'lib/repository.rb', line 22 def delete id Commands::Delete.new(id: id, head: @head).call end |
#read(id) ⇒ Object
18 19 20 |
# 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 |