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.



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

def initialize(context = {})
  @context = Lite::Command::Context.build(context)
  Utils.hook(self, :on_pending)
end

Instance Attribute Details

#contextObject (readonly) Also known as: ctx

Returns the value of attribute context.



28
29
30
# File 'lib/lite/command/base.rb', line 28

def context
  @context
end

Class Method Details

.inherited(base) ⇒ Object



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

def self.inherited(base)
  base.include Lite::Command::Internals::Context
  base.include Lite::Command::Internals::Call
  base.include Lite::Command::Internals::Execute
  base.include Lite::Command::Internals::Fault
  base.include Lite::Command::Internals::Result

  base.class_eval <<-RUBY, __FILE__, __LINE__ + 1
    # eg: Users::ResetPassword::Fault < Lite::Command::Fault
    #{base}::Fault = Class.new(Lite::Command::Fault)

    # eg: Users::ResetPassword::Noop < Users::ResetPassword::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

  super
end