module Cuprum::Rails::Responders::Matching::ClassMethods
Provides a DSL for generating response clauses for matching results.
Attributes
matcher[R]
Public Instance Methods
match(status, error: nil, value: nil, &block)
click to toggle source
Creates a match clause that maps a result to a response.
@param status [Symbol] The status of the result, either :success or
:failure.
@param error [Class] The class of the result error. If given, the clause
will only match results with an error that is an instance of this class or a subclass.
@param value [Class] The class of the result value. If given, the clause
will only match results with a value that is an instance of this class or a subclass.
@yield The clause implementation. This block will be called in the
context of the matcher.
@yieldreturn [#call, renderer] the response for the action.
# File lib/cuprum/rails/responders/matching.rb, line 27 def match(status, error: nil, value: nil, &block) matcher = @matcher || Cuprum::Matcher.new matcher.singleton_class.match( status, error: error, value: value, &block ) @matcher = matcher end
matchers(**_keywords)
click to toggle source
@private
# File lib/cuprum/rails/responders/matching.rb, line 38 def matchers(**_keywords) return [] unless @matcher [@matcher] end