Class: Ingress::PermissionsDsl
- Inherits:
-
Object
- Object
- Ingress::PermissionsDsl
- Defined in:
- lib/ingress/permissions_dsl.rb
Instance Attribute Summary collapse
-
#permission_repository ⇒ Object
readonly
Returns the value of attribute permission_repository.
-
#role_identifier ⇒ Object
readonly
Returns the value of attribute role_identifier.
Instance Method Summary collapse
- #can(actions, subjects, options = {}, &block) ⇒ Object
- #can_do_anything ⇒ Object
- #cannot(actions, subjects, options = {}, &block) ⇒ Object
-
#initialize(role_identifier) ⇒ PermissionsDsl
constructor
A new instance of PermissionsDsl.
Constructor Details
#initialize(role_identifier) ⇒ PermissionsDsl
Returns a new instance of PermissionsDsl.
7 8 9 10 |
# File 'lib/ingress/permissions_dsl.rb', line 7 def initialize(role_identifier) @role_identifier = role_identifier @permission_repository = PermissionsRepository.new end |
Instance Attribute Details
#permission_repository ⇒ Object (readonly)
Returns the value of attribute permission_repository.
5 6 7 |
# File 'lib/ingress/permissions_dsl.rb', line 5 def @permission_repository end |
#role_identifier ⇒ Object (readonly)
Returns the value of attribute role_identifier.
5 6 7 |
# File 'lib/ingress/permissions_dsl.rb', line 5 def role_identifier @role_identifier end |
Instance Method Details
#can(actions, subjects, options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/ingress/permissions_dsl.rb', line 16 def can(actions, subjects, = {}, &block) for_each_action_and_subject(actions, subjects) do |action, subject| conditions = conditions_from(, block) .(role_identifier, true, action, subject, conditions) end end |
#can_do_anything ⇒ Object
12 13 14 |
# File 'lib/ingress/permissions_dsl.rb', line 12 def can_do_anything .(role_identifier, true, "*", "*") end |
#cannot(actions, subjects, options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ingress/permissions_dsl.rb', line 24 def cannot(actions, subjects, = {}, &block) for_each_action_and_subject(actions, subjects) do |action, subject| conditions = conditions_from(, block) .(role_identifier, false, action, subject, conditions) end end |