Module: Hypernova::PluginHelper

Included in:
BatchRenderer, ControllerHelpers, RequestService
Defined in:
lib/hypernova/plugin_helper.rb

Instance Method Summary collapse

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

#send_request?(jobs_hash) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
# File 'lib/hypernova/plugin_helper.rb', line 22

def send_request?(jobs_hash)
  Hypernova.plugins.all? do |plugin|
    if plugin.respond_to?(:send_request?)
      plugin.send_request?(jobs_hash)
    else
      true
    end
  end
end

#will_send_request(jobs_hash) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/hypernova/plugin_helper.rb', line 32

def will_send_request(jobs_hash)
  Hypernova.plugins.each do |plugin|
    if plugin.respond_to?(:will_send_request)
      plugin.will_send_request(jobs_hash)
    end
  end
end