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.
-
#strong_params ⇒ Object
readonly
Returns the value of attribute strong_params.
Instance Method Summary collapse
-
#initialize(actions, privilege, context, strong_params, 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, strong_params, attribute_check = false, load_object_model = nil, load_object_method = nil, filter_block = nil) ⇒ ControllerPermission
Returns a new instance of ControllerPermission.
638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/declarative_authorization/in_controller.rb', line 638 def initialize (actions, privilege, context, strong_params, 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 @strong_params = strong_params end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
637 638 639 |
# File 'lib/declarative_authorization/in_controller.rb', line 637 def actions @actions end |
#attribute_check ⇒ Object (readonly)
Returns the value of attribute attribute_check.
637 638 639 |
# File 'lib/declarative_authorization/in_controller.rb', line 637 def attribute_check @attribute_check end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
637 638 639 |
# File 'lib/declarative_authorization/in_controller.rb', line 637 def context @context end |
#privilege ⇒ Object (readonly)
Returns the value of attribute privilege.
637 638 639 |
# File 'lib/declarative_authorization/in_controller.rb', line 637 def privilege @privilege end |
#strong_params ⇒ Object (readonly)
Returns the value of attribute strong_params.
637 638 639 |
# File 'lib/declarative_authorization/in_controller.rb', line 637 def strong_params @strong_params end |
Instance Method Details
#matches?(action_name) ⇒ Boolean
651 652 653 |
# File 'lib/declarative_authorization/in_controller.rb', line 651 def matches? (action_name) @actions.include?(action_name.to_sym) end |
#permit!(contr) ⇒ Object
655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/declarative_authorization/in_controller.rb', line 655 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
669 670 671 672 |
# File 'lib/declarative_authorization/in_controller.rb', line 669 def remove_actions (actions) @actions -= actions self end |