class Lite::Command::Complex

Attributes

args[R]
result[R]

Public Class Methods

call(*args, **kwargs, &block) click to toggle source
# File lib/lite/command/complex.rb, line 9
def call(*args, **kwargs, &block)
  klass = new(*args, **kwargs, &block)
  raise Lite::Command::NotImplementedError unless klass.respond_to?(:execute)

  klass.call
  klass
end
execute(*args, **kwargs, &block) click to toggle source
# File lib/lite/command/complex.rb, line 17
def execute(*args, **kwargs, &block)
  klass = call(*args, **kwargs, &block)
  klass.result
end
new(*args) click to toggle source
# File lib/lite/command/complex.rb, line 26
def initialize(*args)
  @args = args
end

Public Instance Methods

call() click to toggle source
# 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?() click to toggle source
# File lib/lite/command/complex.rb, line 38
def called?
  @called ||= false
end
recall!() click to toggle source
# 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