Class: Authorization::ControllerPermission
- Inherits:
-
Object
- Object
- Authorization::ControllerPermission
- Defined in:
- lib/declarative_authorization/in_controller.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#attribute_check ⇒ Object
readonly
Returns the value of attribute attribute_check.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#privilege ⇒ Object
readonly
Returns the value of attribute privilege.
Instance Method Summary collapse
-
#initialize(actions, privilege, context, attribute_check = false, load_object_model = nil, load_object_method = nil, filter_block = nil) ⇒ ControllerPermission
constructor
A new instance of ControllerPermission.
- #matches?(action_name) ⇒ Boolean
- #permit!(contr) ⇒ Object
- #remove_actions(actions) ⇒ Object
Constructor Details
#initialize(actions, privilege, context, attribute_check = false, load_object_model = nil, load_object_method = nil, filter_block = nil) ⇒ ControllerPermission
Returns a new instance of ControllerPermission.
583 584 585 586 587 588 589 590 591 592 593 |
# File 'lib/declarative_authorization/in_controller.rb', line 583 def initialize (actions, privilege, context, attribute_check = false, load_object_model = nil, load_object_method = nil, filter_block = nil) @actions = actions.to_set @privilege = privilege @context = context @load_object_model = load_object_model @load_object_method = load_object_method @filter_block = filter_block @attribute_check = attribute_check end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
582 583 584 |
# File 'lib/declarative_authorization/in_controller.rb', line 582 def actions @actions end |
#attribute_check ⇒ Object (readonly)
Returns the value of attribute attribute_check.
582 583 584 |
# File 'lib/declarative_authorization/in_controller.rb', line 582 def attribute_check @attribute_check end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
582 583 584 |
# File 'lib/declarative_authorization/in_controller.rb', line 582 def context @context end |
#privilege ⇒ Object (readonly)
Returns the value of attribute privilege.
582 583 584 |
# File 'lib/declarative_authorization/in_controller.rb', line 582 def privilege @privilege end |
Instance Method Details
#matches?(action_name) ⇒ Boolean
595 596 597 |
# File 'lib/declarative_authorization/in_controller.rb', line 595 def matches? (action_name) @actions.include?(action_name.to_sym) end |
#permit!(contr) ⇒ Object
599 600 601 602 603 604 605 606 607 608 609 610 611 |
# File 'lib/declarative_authorization/in_controller.rb', line 599 def permit! (contr) if @filter_block return contr.instance_eval(&@filter_block) end object = @attribute_check ? load_object(contr) : nil privilege = @privilege || :"#{contr.action_name}" contr..permit!(privilege, :user => contr.send(:current_user), :object => object, :skip_attribute_test => !@attribute_check, :context => @context || contr.class.decl_auth_context) end |
#remove_actions(actions) ⇒ Object
613 614 615 616 |
# File 'lib/declarative_authorization/in_controller.rb', line 613 def remove_actions (actions) @actions -= actions self end |