Class: CemAcpt::ActionResult
- Inherits:
-
Object
- Object
- CemAcpt::ActionResult
- Defined in:
- lib/cem_acpt/action_result.rb
Overview
Wrapper class for the result of an action. Provides a common interface for getting reportable data from the result.
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(result) ⇒ ActionResult
constructor
A new instance of ActionResult.
- #method_missing(method_name, *args, **kwargs, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(result) ⇒ ActionResult
Returns a new instance of ActionResult.
7 8 9 10 11 12 13 |
# File 'lib/cem_acpt/action_result.rb', line 7 def initialize(result) @result = if result.instance_of?(CemAcpt::Goss::Api::ActionResponse) result else ErrorActionResult.new(result) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, **kwargs, &block) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/cem_acpt/action_result.rb', line 19 def method_missing(method_name, *args, **kwargs, &block) if @result.respond_to?(method_name) @result.send(method_name, *args, **kwargs, &block) else super end end |
Instance Method Details
#error? ⇒ Boolean
15 16 17 |
# File 'lib/cem_acpt/action_result.rb', line 15 def error? @result.is_a?(ErrorActionResult) end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
27 28 29 |
# File 'lib/cem_acpt/action_result.rb', line 27 def respond_to_missing?(method_name, include_private = false) @result.respond_to?(method_name, include_private) || super end |