Class: Hecks::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/create.rb,
lib/commands/delete.rb,
lib/commands/runner.rb,
lib/commands/update.rb,
lib/hecks-application.rb,
lib/queries/find_by_id.rb,
lib/queries/query_runner.rb,
lib/commands/crud_handler.rb

Defined Under Namespace

Modules: Commands, Queries Classes: QueryRunner, Runner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database: nil, listeners: [], domain:) ⇒ Application

Returns a new instance of Application.



22
23
24
25
26
27
28
# File 'lib/hecks-application.rb', line 22

def initialize(database: nil, listeners: [], domain:)
  load(domain.spec_path)
  @domain      = domain
  @database    = database
  @events_port = Adapters::Events.new(listeners: listeners)
  @domain_spec = DOMAIN
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



21
22
23
# File 'lib/hecks-application.rb', line 21

def database
  @database
end

#domain_specObject (readonly)

Returns the value of attribute domain_spec.



21
22
23
# File 'lib/hecks-application.rb', line 21

def domain_spec
  @domain_spec
end

#events_portObject (readonly)

Returns the value of attribute events_port.



21
22
23
# File 'lib/hecks-application.rb', line 21

def events_port
  @events_port
end

Instance Method Details

#[](module_name) ⇒ Object



39
40
41
# File 'lib/hecks-application.rb', line 39

def [](module_name)
  Commands::CRUDHandler.new(module_name: module_name, application: self)
end

#call(command_name:, module_name:, args: {}) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/hecks-application.rb', line 30

def call(command_name:, module_name:, args: {})
  Runner.new(
    command_name: command_name,
    module_name:  module_name,
    args:         args,
    application:  self
  ).call
end

#query(query_name:, module_name:, args: {}) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/hecks-application.rb', line 43

def query(query_name:, module_name:, args: {})
  QueryRunner.new(
    module_name: module_name,
    query_name:  query_name,
    args:        args,
    application: self
  ).call
end