module RailsCom::ControllerHelper

Public Instance Methods

detect_filter(filter) click to toggle source
# File lib/rails_com/action_controller/controller_helper.rb, line 3
def detect_filter(filter)
  callback = self.__callbacks[:process_action].find { |i| i.filter == filter.to_sym }
  return false unless callback

  _if = callback.instance_variable_get(:@if).map do |c|
    c.call(self)
  end

  _unless = callback.instance_variable_get(:@unless).map do |c|
    !c.call(self)
  end

  !(_if + _unless).uniq.include?(false)
end