lib/jets/controller/callbacks.rb in jets-3.0.6 vs lib/jets/controller/callbacks.rb in jets-3.0.7

- old
+ new

@@ -15,14 +15,16 @@ def prepend_before_action(meth, options = {}) self.before_actions = [[meth, options]] + self.before_actions end def skip_before_action(meth, options = {}) - # adds the methods in the only to the exception list for the callback - return append_except_to_callbacks(self.before_actions, meth, options[:only]) if options[:only].present? - - self.before_actions.reject! { |el| el.first.to_s == meth.to_s } + self.before_actions = before_actions + .reject { |act| act.first.to_s == meth.to_s } + + # If options include the `only` option, + # re-add the action using the setter with the `except` option + before_action(meth, { except: options[:only] }) if options[:only].present? end alias_method :append_before_action, :before_action def after_action(meth, options = {}) @@ -36,23 +38,9 @@ def skip_after_action(meth) self.after_actions = self.after_actions.reject { |el| el.first.to_s == meth.to_s } end alias_method :append_after_action, :after_action - - private - - def append_except_to_callbacks(callback_methods, meth, excepted_methods) - callback_methods.map! do |callback_method| - if callback_method.first.to_s == meth.to_s - exceptions = callback_method.second[:except] || [] - exceptions.concat(Array.wrap(excepted_methods)) - callback_method.second[:except] = exceptions - end - - callback_method - end - end end end # included # Instance Methods # define run_before_actions and run_after_actions