Module: Constellation::Authorization::Base::ControllerClassMethods

Defined in:
lib/constellation/authorization/base.rb

Instance Method Summary collapse

Instance Method Details

#permit(authorization_expression, *args) ⇒ Object

Allow class-level authorization check. permit is used in a before_filter fashion and passes arguments to the before_filter.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/constellation/authorization/base.rb', line 18

def permit(authorization_expression, *args)
  filter_keys = [:only, :except]
  filter_args, eval_args = {}, {}
  if args.last.is_a? Hash
    filter_args.merge!(args.last.reject {|k,v| not filter_keys.include? k })
    eval_args.merge!(args.last.reject {|k,v| filter_keys.include? k })
  end
  before_filter(filter_args) do |controller|
    controller.permit(authorization_expression, eval_args)
  end
end