class Lite::Commands::Base

Attributes

result[R]

Public Class Methods

call(*args) click to toggle source
# File lib/lite/commands/base.rb, line 9
def call(*args)
  klass = new(*args)
  klass.call
  klass
end
new(*args) click to toggle source
# File lib/lite/commands/base.rb, line 24
def initialize(*args)
  @args = args
end
run(*args) click to toggle source
# File lib/lite/commands/base.rb, line 15
def run(*args)
  klass = call(*args)
  klass.result
end

Public Instance Methods

call() click to toggle source
# File lib/lite/commands/base.rb, line 28
def call
  raise Lite::Commands::NotImplementedError unless defined?(command)
  return @result if called?

  @called = true
  @result = command
end
called?() click to toggle source
# File lib/lite/commands/base.rb, line 36
def called?
  @called ||= false
end
recall!() click to toggle source
# File lib/lite/commands/base.rb, line 40
def recall!
  @called = false
  %i[cache errors].each { |mixin| send(mixin).clear if respond_to?(mixin) }
  call
end