Sha256: 6681f083649c3305e3dfd780dabdb2a51744a9f25a8e7dceb5f5cd6421001b02
Contents?: true
Size: 795 Bytes
Versions: 2
Compression:
Stored size: 795 Bytes
Contents
# frozen_string_literal: true module Lite module Command class Complex class << self def call(*args) klass = new(*args) klass.call klass end def run(*args) klass = call(*args) klass.result end end attr_reader :result def initialize(*args) @args = args end def call raise Lite::Command::NotImplementedError unless defined?(command) return @result if called? @called = true @result = command end def called? @called ||= false end def recall! @called = false %i[cache errors].each { |mixin| send(mixin).clear if respond_to?(mixin) } call end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lite-command-1.0.1 | lib/lite/command/complex.rb |
lite-command-1.0.0 | lib/lite/command/complex.rb |