Module: Paloma::ActionControllerExtension::InstanceMethods
- Defined in:
- lib/paloma/action_controller_extension.rb
Instance Method Summary collapse
-
#insert_paloma_hook ⇒ Object
Call in your view to insert Paloma’s html hook.
-
#js(path_or_options, params = {}) ⇒ Object
Specify the behavior of Paloma.
-
#track_paloma_request ⇒ Object
Executed every time a controller action is executed.
Instance Method Details
#insert_paloma_hook ⇒ Object
Call in your view to insert Paloma’s html hook.
The html hook contains the javascript code that will execute the tracked Paloma requests.
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/paloma/action_controller_extension.rb', line 136 def insert_paloma_hook return nil if self.paloma.has_no_request? hook = view_context.render( :partial => 'paloma/hook', :locals => {:request => self.paloma.request}) self.paloma.clear_request hook end |
#js(path_or_options, params = {}) ⇒ Object
Specify the behavior of Paloma. Call this manually to override the default Paloma controller/action to be executed.
Can call a different Controller or execute a different action, and pass parameters.
NOTE: Calling this more than once in a single action will not clear the previous config from the previous call.
Example: def new
js 'MyController#new'
js :edit
js :x => 1, :y => 2
# Paloma will execute JS for
# MyController#edit and will pass the parameters :x => 1, :y => 2
end
Usage:
js 'Controller', {params}
js 'Controller#action', {params}
js 'Namespace/Controller', {params}
js 'Namespace/Controller#action', {params}
js '#action', {params}
js :action, {params}
js :param_1 => 1, :param_2 => 2
js true
js false
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/paloma/action_controller_extension.rb', line 83 def js , params = {} return self.paloma.clear_request if ! self.paloma.params.merge! params || {} # # 'Controller' # 'Controller#action' # 'Namespace/Controller' # 'Namespace/Controller#action' # '#action' # if .is_a? String route = ::Paloma::Utilities.interpret_route self.paloma.resource = route[:resource] if route[:resource].present? self.paloma.action = route[:action] if route[:action].present? # :action elsif .is_a? Symbol self.paloma.action = # :param_1 => 1, :param_2 => 2 elsif .is_a? Hash self.paloma.params.merge! || {} elsif != true raise "Paloma: Invalid argument (#{}) for js method" end self.paloma.resource ||= self.default_resource self.paloma.action ||= self.default_action self.paloma.save_request_history end |
#track_paloma_request ⇒ Object
Executed every time a controller action is executed.
Keeps track of what Rails controller/action is executed.
124 125 126 127 |
# File 'lib/paloma/action_controller_extension.rb', line 124 def track_paloma_request self.paloma.resource ||= self.default_resource self.paloma.action ||= self.default_action end |