Module: Swamp::Controller

Defined in:
lib/swamp/rails_actions/controller.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/swamp/rails_actions/controller.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#action!(klass, **kwargs) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/swamp/rails_actions/controller.rb', line 9

def action!(klass, **kwargs)
  result = klass.new.call(params.to_unsafe_h.merge(request: request, **kwargs))

  setup_exposures!(klass, result)

  if result.render?
    render_result(result, klass)
  elsif result.redirect?
    redirect_result(result, klass)
  end
end