Module: Rad::Controller::Authorized::ClassMethods

Defined in:
lib/kit/controller/authorized.rb

Instance Method Summary collapse

Instance Method Details

#require_permission(operation, *args, &object_proc) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/kit/controller/authorized.rb', line 7

def require_permission operation, *args, &object_proc
  operation.must_be.a Symbol

  options = args.extract_options!
  # object_proc = args.size > 0 ? args.first : lambda{}
  object_proc ||= lambda{|controller|}

  method = "require_permission_#{operation}".to_sym
  define_method method do
    require_permission operation, instance_eval(&object_proc)
  end

  before method, options
end