Module: TShield::Controller::ClassMethods

Defined in:
lib/tshield/controller.rb

Overview

Implementation of actions

Instance Method Summary collapse

Instance Method Details

#action(class_method, options) ⇒ Object



16
17
18
19
# File 'lib/tshield/controller.rb', line 16

def action(class_method, options)
  @actions = {} unless defined? @actions
  @actions[class_method] = options
end

#load_action(app, class_method, options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/tshield/controller.rb', line 27

def load_action(app, class_method, options)
  msg = "== registering #{options[:path]}"
  msg << " for methods #{options[:methods].join(',')}"
  msg << " with action #{class_method}"

  TShield.logger.info(msg)
  options[:methods].each do |method|
    app.send(method, options[:path]) do
      send(class_method, params, request)
    end
  end
end

#registered(app) ⇒ Object



21
22
23
24
25
# File 'lib/tshield/controller.rb', line 21

def registered(app)
  @actions.each do |class_method, options|
    load_action(app, class_method, options)
  end
end