Class: CemAcpt::ActionResult

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (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

Returns:

  • (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