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

Defined in:
lib/cuprum/rails/responders/actions.rb

Overview

Provides a DSL for generating action-specific response clauses.

Instance Method Summary collapse

Instance Method Details

#action(action_name) { ... } ⇒ Object

Creates a new response matcher specific to the specified action.

Parameters:

  • action_name (String, Symbol)

    The name of the action.

Yields:

  • The matcher definition.



17
18
19
20
21
22
23
# 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

#actionsObject



26
27
28
# File 'lib/cuprum/rails/responders/actions.rb', line 26

def actions
  @actions ||= {}
end

#matchers(action_name: nil, **_keywords) ⇒ Object



31
32
33
34
35
36
37
# 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