diff --git a/README.md b/README.md index 30c9aab..d62b3d6 100644 --- a/README.md +++ b/README.md @@ -150,7 +150,7 @@ class HypernovaPlugin # prepare_request allows you to alter the request object in any way that you # need. # Unless manipulated by another plugin, request takes the shape: - # { 'component_name.js': { :name => 'component_name.js', :data => {} } } + # [{ :name => 'component_name.js', :data => {} }, ...] def prepare_request(current_request, original_request) current_request.keys.each do |key| phrase_hash = req[key][:data][:phrases] diff --git a/lib/hypernova/controller_helpers.rb b/lib/hypernova/controller_helpers.rb index f3d4b80..7d89b91 100644 --- a/lib/hypernova/controller_helpers.rb +++ b/lib/hypernova/controller_helpers.rb @@ -78,17 +78,15 @@ def hypernova_batch_after return if @hypernova_batch.empty? jobs = @hypernova_batch.jobs - hash = jobs.each_with_object({}) do |job, h| - h[job[:name]] = job - end - hash = prepare_request(hash, hash) - if send_request?(hash) + jobs = prepare_request(jobs, jobs) + + if send_request?(jobs) begin - will_send_request(hash) + will_send_request(jobs) result = @hypernova_batch.submit! - on_success(result, hash) + on_success(result, jobs) rescue StandardError => e - on_error(e, nil, hash) + on_error(e, nil, jobs) result = @hypernova_batch.submit_fallback! end else diff --git a/lib/hypernova/plugin_helper.rb b/lib/hypernova/plugin_helper.rb index cf92b9c..b3963bd 100644 --- a/lib/hypernova/plugin_helper.rb +++ b/lib/hypernova/plugin_helper.rb @@ -19,20 +19,20 @@ def prepare_request(current_request, original_request) end end - def send_request?(jobs_hash) + def send_request?(jobs) Hypernova.plugins.all? do |plugin| if plugin.respond_to?(:send_request?) - plugin.send_request?(jobs_hash) + plugin.send_request?(jobs) else true end end end - def will_send_request(jobs_hash) + def will_send_request(jobs) Hypernova.plugins.each do |plugin| if plugin.respond_to?(:will_send_request) - plugin.will_send_request(jobs_hash) + plugin.will_send_request(jobs) end end end @@ -47,13 +47,13 @@ def after_response(current_response, original_response) end end - 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) } + def on_error(error, job = nil, jobs = nil) + Hypernova.plugins.each { |plugin| plugin.on_error(error, job, jobs) if plugin.respond_to?(:on_error) } end - def on_success(res, jobs_hash) + def on_success(res, jobs) Hypernova.plugins.each do |plugin| - plugin.on_success(res, jobs_hash) if plugin.respond_to?(:on_success) + plugin.on_success(res, jobs) if plugin.respond_to?(:on_success) end end end diff --git a/lib/hypernova/version.rb b/lib/hypernova/version.rb index f2c9af9..d1852e4 100644 --- a/lib/hypernova/version.rb +++ b/lib/hypernova/version.rb @@ -1,3 +1,3 @@ module Hypernova - VERSION = "1.4.0" + VERSION = "2.0.0" end