Module: Crystal::HttpController::Authorized::SingletonMethods

Defined in:
lib/rad/http_controller/acts_as/authorized.rb

Instance Method Summary collapse

Instance Method Details

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rad/http_controller/acts_as/authorized.rb', line 16

def require_permission operation, *args, &object_proc
  operation = operation.must_be.a([String, Symbol]).to_s
  # operation.should! :be_in, Space.permissions

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

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