module Cuprum::Rails::Responders::Actions::ClassMethods
Provides a DSL for generating action-specific response clauses.
Public Instance Methods
action(action_name, &block)
click to toggle source
Creates a new response matcher specific to the specified action.
@param action_name [String, Symbol] The name of the action.
@yield The matcher definition.
# File lib/cuprum/rails/responders/actions.rb, line 17 def action(action_name, &block) validate_action_name!(action_name) actions[action_name.intern] = Cuprum::Matcher.new(&block) nil end
actions()
click to toggle source
@private
# File lib/cuprum/rails/responders/actions.rb, line 26 def actions @actions ||= {} end
matchers(action_name: nil, **_keywords)
click to toggle source
@private
Calls superclass method
# File lib/cuprum/rails/responders/actions.rb, line 31 def matchers(action_name: nil, **_keywords) return super unless action_name action = actions[action_name.intern] action.nil? ? super : [action, *super] end
Private Instance Methods
validate_action_name!(action_name)
click to toggle source
# File lib/cuprum/rails/responders/actions.rb, line 41 def validate_action_name!(action_name) if action_name.nil? || action_name.to_s.empty? raise ArgumentError, "action name can't be blank", caller(1..-1) end return if action_name.is_a?(String) || action_name.is_a?(Symbol) raise ArgumentError, 'action name must be a String or Symbol', caller(1..-1) end