Class: Lite::Service::Base
- Inherits:
-
Object
- Object
- Lite::Service::Base
- Defined in:
- lib/lite/service/base.rb
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #called? ⇒ Boolean
-
#initialize(*args) ⇒ Base
constructor
A new instance of Base.
- #recall! ⇒ Object
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
24 25 26 |
# File 'lib/lite/service/base.rb', line 24 def initialize(*args) @args = args end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
22 23 24 |
# File 'lib/lite/service/base.rb', line 22 def result @result end |
Class Method Details
.call(*args) ⇒ Object
9 10 11 12 13 |
# File 'lib/lite/service/base.rb', line 9 def call(*args) klass = new(*args) klass.call klass end |
.run(*args) ⇒ Object
15 16 17 18 |
# File 'lib/lite/service/base.rb', line 15 def run(*args) klass = new(*args) klass.call end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/lite/service/base.rb', line 28 def call raise Lite::Service::NotImplementedError unless defined?(command) return @result if called? @called = true @result = command end |
#called? ⇒ Boolean
36 37 38 |
# File 'lib/lite/service/base.rb', line 36 def called? @called ||= false end |
#recall! ⇒ Object
40 41 42 43 44 |
# File 'lib/lite/service/base.rb', line 40 def recall! @called = false %i[cache errors].each { |mixin| send(mixin).clear if respond_to?(mixin) } call end |