Class: FunctionalLightService::Sequencer::OperationWrapper

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/functional-light-service/functional/sequencer.rb

Overview

OperationWrapper proxies all method calls to the wrapped instance, but first checks if the name of the called method matches a value stored within @gotten_results and returns the value if it does.

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ OperationWrapper

Returns a new instance of OperationWrapper.



122
123
124
125
# File 'lib/functional-light-service/functional/sequencer.rb', line 122

def initialize(*args)
  super
  @gotten_results = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs) ⇒ Object



127
128
129
130
131
132
133
# File 'lib/functional-light-service/functional/sequencer.rb', line 127

def method_missing(name, *args, **kwargs, &)
  if @gotten_results.key?(name)
    @gotten_results[name]
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/functional-light-service/functional/sequencer.rb', line 135

def respond_to_missing?(name, include_private = false)
  @gotten_results.key?(name) || super
end