Class: HecksApplication

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

Overview

The Applicaiton port. Adapters usually talk to the domain through HecksApplication

Defined Under Namespace

Modules: Commands, Queries Classes: CommandRunner, QueryRunner, Validator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database: nil, listeners: [], domain:, validator: HecksApplication::Validator) ⇒ HecksApplication

Returns a new instance of HecksApplication.



18
19
20
21
22
23
24
25
# File 'lib/hecks-application.rb', line 18

def initialize(database: nil, listeners: [], domain:, validator: HecksApplication::Validator)
  load(domain.spec_path)
  @domain      = domain
  @database    = database
  @events_port = HecksEvents.new(listeners: listeners)
  @domain_spec = DOMAIN
  @validator   = validator
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



17
18
19
# File 'lib/hecks-application.rb', line 17

def database
  @database
end

#domain_specObject (readonly)

Returns the value of attribute domain_spec.



17
18
19
# File 'lib/hecks-application.rb', line 17

def domain_spec
  @domain_spec
end

#events_portObject (readonly)

Returns the value of attribute events_port.



17
18
19
# File 'lib/hecks-application.rb', line 17

def events_port
  @events_port
end

#validatorObject (readonly)

Returns the value of attribute validator.



17
18
19
# File 'lib/hecks-application.rb', line 17

def validator
  @validator
end

Instance Method Details

#[](module_name) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/hecks-application.rb', line 36

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

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



27
28
29
30
31
32
33
34
# File 'lib/hecks-application.rb', line 27

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

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



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

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