Class: Lite::Command::Complex
- Inherits:
-
Object
- Object
- Lite::Command::Complex
- Defined in:
- lib/lite/command/complex.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #called? ⇒ Boolean
-
#initialize(*args) ⇒ Complex
constructor
A new instance of Complex.
- #recall! ⇒ Object
Constructor Details
#initialize(*args) ⇒ Complex
Returns a new instance of Complex.
26 27 28 |
# File 'lib/lite/command/complex.rb', line 26 def initialize(*args) @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
24 25 26 |
# File 'lib/lite/command/complex.rb', line 24 def args @args end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
24 25 26 |
# File 'lib/lite/command/complex.rb', line 24 def result @result end |
Class Method Details
.call(*args) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/lite/command/complex.rb', line 9 def call(*args) klass = new(*args) raise Lite::Command::NotImplementedError unless klass.respond_to?(:execute) klass.call klass end |
.execute(*args) ⇒ Object
17 18 19 20 |
# File 'lib/lite/command/complex.rb', line 17 def execute(*args) klass = call(*args) klass.result end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/lite/command/complex.rb', line 30 def call raise Lite::Command::NotImplementedError unless defined?(execute) return @result if called? @called = true @result = execute end |
#called? ⇒ Boolean
38 39 40 |
# File 'lib/lite/command/complex.rb', line 38 def called? @called ||= false end |
#recall! ⇒ Object
42 43 44 45 46 |
# File 'lib/lite/command/complex.rb', line 42 def recall! @called = false %i[cache errors].each { |mixin| send(mixin).clear if respond_to?(mixin) } call end |