mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Fix easy rubocop issues
This commit is contained in:
@@ -1,27 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Spree
|
||||
class Responder < ::ActionController::Responder #:nodoc:
|
||||
|
||||
attr_accessor :on_success, :on_failure
|
||||
|
||||
def initialize(controller, resources, options={})
|
||||
def initialize(controller, resources, options = {})
|
||||
super
|
||||
|
||||
class_name = controller.class.name.to_sym
|
||||
action_name = options.delete(:action_name)
|
||||
|
||||
if result = Spree::BaseController.spree_responders[class_name].try(:[], action_name).try(:[], self.format.to_sym)
|
||||
self.on_success = handler(controller, result, :success)
|
||||
self.on_failure = handler(controller, result, :failure)
|
||||
end
|
||||
result = Spree::BaseController.spree_responders[class_name].
|
||||
try(:[], action_name).
|
||||
try(:[], self.format.to_sym)
|
||||
return unless result
|
||||
|
||||
self.on_success = handler(controller, result, :success)
|
||||
self.on_failure = handler(controller, result, :failure)
|
||||
end
|
||||
|
||||
def to_html
|
||||
super and return if !(on_success || on_failure)
|
||||
if !(on_success || on_failure)
|
||||
super
|
||||
return
|
||||
end
|
||||
|
||||
has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success)
|
||||
end
|
||||
|
||||
def to_format
|
||||
super and return if !(on_success || on_failure)
|
||||
if !(on_success || on_failure)
|
||||
super
|
||||
return
|
||||
end
|
||||
|
||||
has_errors? ? controller.instance_exec(&on_failure) : controller.instance_exec(&on_success)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user