class HecksAdapters::SQLDatabase::Repository

Translates calls from an application into SQL Commands

Public Class Methods

new(module_name:) click to toggle source
# File lib/repository.rb, line 5
def initialize(module_name:)
  @module_name = module_name
  @head = DOMAIN[module_name].head
end

Public Instance Methods

create(attributes) click to toggle source
# File lib/repository.rb, line 10
def create attributes
  Commands::Create.new(attributes: attributes, head: @head).call
end
delete(id) click to toggle source
# File lib/repository.rb, line 22
def delete id
  Commands::Delete.new(id: id, head: @head).call
end
read(id) click to toggle source
# 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) click to toggle source
# File lib/repository.rb, line 14
def update id, attributes
  Commands::Update.new(id: id, attributes: attributes, head: @head).call
end

Private Instance Methods

entity_class() click to toggle source
# File lib/repository.rb, line 28
def entity_class
  DOMAIN.name.camelcase.constantize::Domain.const_get(@module_name).head
end