Module: Cuprum::Rails::Responders::Actions

Included in:
HtmlResponder, JsonResponder
Defined in:
lib/cuprum/rails/responders/actions.rb

Overview

Implements matching a result to action-specific response clauses.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object



61
62
63
64
65
# File 'lib/cuprum/rails/responders/actions.rb', line 61

def self.included(other)
  super

  other.extend(ClassMethods)
end

Instance Method Details

#call(result) ⇒ #call

Finds and calls the response clause that matches the given result.

  1. Checks for an exact match (the result status, value, and error all match) in the given matcher (if any), then the responder class, then each ancestor of the responder class in ascending order.

  2. If a match is not found, checks for a partial match (the result status, and either the value or the error match) in the same order.

  3. If there is still no match found, checks for a generic match (the result status matches, and the match clause does not specify either an error or a value.

  4. If there is no matching response clause, raises an exception.

If the responder defines an action matcher that matches the given action name, that matcher is matched against the result before any match clauses defined directly on the responder.

Parameters:

  • result (Cuprum::Result)

    the result of the action call.

Returns:

  • (#call)

    the response object from the matching response clause.

Raises:

  • (Cuprum::Matching::NoMatchError)

    if none of the response clauses match the result.



# File 'lib/cuprum/rails/responders/actions.rb', line 53