Skip to content

Instantly share code, notes, and snippets.

@jameskerr
Last active March 24, 2017 17:20
Show Gist options
  • Save jameskerr/2fe90680a998b8373867993581615168 to your computer and use it in GitHub Desktop.
Save jameskerr/2fe90680a998b8373867993581615168 to your computer and use it in GitHub Desktop.
# Put this in the controller
def filters_for_this_action
_process_action_callbacks.select do |filter|
ifs = filter.options[:if].first || 'true'
unlesses = filter.options[:unless].first || 'false'
eval(ifs) && !eval(unlesses)
end.map { |filter| [filter.kind, filter.filter] }
end
# Put this in the action
def create
puts filters_for_this_action
end
# And the output looks like this
[[:before, :flip_cookie_strategy_before],
[:after, :flip_cookie_strategy_after],
[:before, :initialize_product_branding],
[:before, :allow_all_if_third_party_origin],
[:before, :set_cache_buster],
[:before, :set_page_vars],
[:after, :set_version_header],
[:after, :set_tracking_cookie],
[:around, :global_request_logging],
[:before, "_callback_before_272(self)"],
[:around, "_callback_around_273 self, Proc.new "],
[:before, :set_current_user],
[:before, :check_current_cycle],
[:before, :refresh_access],
[:before, :check_reviewings_access_and_edit_permission]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment