Class: Lite::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/lite/command/base.rb

Direct Known Subclasses

Sequence

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context = {}) ⇒ Base

Returns a new instance of Base.



36
37
38
39
# File 'lib/lite/command/base.rb', line 36

def initialize(context = {})
  @context = Context.build(context)
  run_hooks(:after_initialize)
end

Instance Attribute Details

#contextObject (readonly) Also known as: ctx

Returns the value of attribute context.



33
34
35
# File 'lib/lite/command/base.rb', line 33

def context
  @context
end

Class Method Details

.inherited(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lite/command/base.rb', line 9

def self.inherited(base)
  super

  base.include ActiveModel::Validations

  base.include Internals::Runtimes
  base.include Internals::Attributes
  base.include Internals::Faults
  base.include Internals::Calls
  base.include Internals::Executions
  base.include Internals::Hooks
  base.include Internals::Results

  if Lite::Command.configuration.raise_dynamic_faults # rubocop:disable Style/GuardClause
    base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
      #{base}::Fault   = Class.new(Lite::Command::Fault)
      #{base}::Noop    = Class.new(#{base}::Fault)
      #{base}::Invalid = Class.new(#{base}::Fault)
      #{base}::Failure = Class.new(#{base}::Fault)
      #{base}::Error   = Class.new(#{base}::Fault)
    RUBY
  end
end