Module: Hypernova::PluginHelper
- Included in:
- BatchRenderer, ControllerHelpers, RequestService
- Defined in:
- lib/hypernova/plugin_helper.rb
Instance Method Summary collapse
- #after_response(current_response, original_response) ⇒ Object
- #get_view_data(name, data) ⇒ Object
- #on_error(error, job = nil, jobs_hash = nil) ⇒ Object
- #on_success(res, jobs_hash) ⇒ Object
- #prepare_request(current_request, original_request) ⇒ Object
- #send_request?(jobs_hash) ⇒ Boolean
- #will_send_request(jobs_hash) ⇒ Object
Instance Method Details
#after_response(current_response, original_response) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/hypernova/plugin_helper.rb', line 40 def after_response(current_response, original_response) Hypernova.plugins.reduce(current_response) do |response, plugin| if plugin.methods.include?(:after_response) plugin.after_response(response, original_response) else response end end end |
#get_view_data(name, data) ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'lib/hypernova/plugin_helper.rb', line 2 def get_view_data(name, data) Hypernova.plugins.reduce(data) do |data, plugin| if plugin.respond_to?(:get_view_data) plugin.get_view_data(name, data) else data end end end |
#on_error(error, job = nil, jobs_hash = nil) ⇒ Object
50 51 52 |
# File 'lib/hypernova/plugin_helper.rb', line 50 def on_error(error, job = nil, jobs_hash = nil) Hypernova.plugins.each { |plugin| plugin.on_error(error, job, jobs_hash) if plugin.respond_to?(:on_error) } end |
#on_success(res, jobs_hash) ⇒ Object
54 55 56 57 58 |
# File 'lib/hypernova/plugin_helper.rb', line 54 def on_success(res, jobs_hash) Hypernova.plugins.each do |plugin| plugin.on_success(res, jobs_hash) if plugin.respond_to?(:on_success) end end |
#prepare_request(current_request, original_request) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/hypernova/plugin_helper.rb', line 12 def prepare_request(current_request, original_request) Hypernova.plugins.reduce(current_request) do |req, plugin| if plugin.respond_to?(:prepare_request) plugin.prepare_request(req, original_request) else req end end end |