Poltergeist in the green, and resourceful refactor

This commit is contained in:
2015-02-27 15:12:08 +01:00
parent d1015dcc88
commit 046058b5d2
31 changed files with 210 additions and 165 deletions
@@ -0,0 +1,21 @@
module ControllerAfterAuthenticationHooks
extend ActiveSupport::Concern
included do
class_attribute :after_authentication_hooks
end
def run_after_authentication_hooks!
Array.wrap(after_authentication_hooks).each do |hook|
next if hook[:options][:only].present? && !Array.wrap(hook[:options][:only]).include?(action_name.to_sym)
instance_eval &hook[:block]
end
end
module ClassMethods
def after_authentication(options, &blk)
self.after_authentication_hooks ||= []
after_authentication_hooks << {options: options, block: blk}
end
end
end