module Apia::CallableWithEnvironment
Public Class Methods
new(environment, action_name: :action)
click to toggle source
# File lib/apia/callable_with_environment.rb, line 6 def initialize(environment, action_name: :action) @environment = environment @action_name = action_name end
Public Instance Methods
call()
click to toggle source
# File lib/apia/callable_with_environment.rb, line 11 def call action = self.class.definition.send(@action_name) return if action.nil? instance_exec(@environment.request, @environment.response, &action) end
call_with_error_handling()
click to toggle source
rubocop:disable Lint/RescueException
# File lib/apia/callable_with_environment.rb, line 19 def call_with_error_handling call rescue Exception => e raise_exception(e) end
method_missing(name, *args, **kwargs, &block)
click to toggle source
Calls superclass method
# File lib/apia/callable_with_environment.rb, line 30 def method_missing(name, *args, **kwargs, &block) if @environment.respond_to?(name) if kwargs.empty? return @environment.send(name, *args, &block) end return @environment.send(name, *args, **kwargs, &block) end super end
respond_to_missing?(name, _include_private = false)
click to toggle source
rubocop:enable Lint/RescueException
Calls superclass method
# File lib/apia/callable_with_environment.rb, line 26 def respond_to_missing?(name, _include_private = false) @environment.respond_to?(name) || super end