Module: SteelWheel::RailsHelpers::ClassMethods

Defined in:
lib/steel_wheel/railtie.rb

Overview

rubocop:disable Style/Documentation

Instance Method Summary collapse

Instance Method Details

#action(action_name, handler: action_name, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/steel_wheel/railtie.rb', line 12

def action(action_name, handler: action_name, &block)
  define_method(action_name) do
    handler_klass = handler_class_for(handler)
    handler_klass.handle(params) do |handler_instance|
      handler_instance.owner = self
      handler_instance.helpers = view_context
      instance_exec(handler_instance, &block)
      failure_callbacks(handler_instance)
    end
  end
end