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
-
#call(result) ⇒ #call
Finds and calls the response clause that matches the given result.
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.
-
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.
-
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.
-
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.
-
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.
|
# File 'lib/cuprum/rails/responders/actions.rb', line 53
|