Class: Ingress::Permissions
- Inherits:
-
Object
- Object
- Ingress::Permissions
- Defined in:
- lib/ingress/permissions.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
- .define_role_permissions(role_identifier = nil, permissions_class = nil, &block) ⇒ Object
- .inherits(permissions_class) ⇒ Object
- .permissions_repository ⇒ Object
Instance Method Summary collapse
- #can?(action, subject) ⇒ Boolean
-
#initialize(user) ⇒ Permissions
constructor
A new instance of Permissions.
- #user_role_identifiers ⇒ Object
Constructor Details
#initialize(user) ⇒ Permissions
Returns a new instance of Permissions.
41 42 43 |
# File 'lib/ingress/permissions.rb', line 41 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
39 40 41 |
# File 'lib/ingress/permissions.rb', line 39 def user @user end |
Class Method Details
.define_role_permissions(role_identifier = nil, permissions_class = nil, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ingress/permissions.rb', line 22 def (role_identifier = nil, = nil, &block) if role_identifier.nil? role_identifier = :dummy end if @permissions_repository = .merge( Services::CopyPermissionsRepositoryIntoRole.perform(role_identifier, .), ) end if block_given? @permissions_repository = .merge(Services::BuildPermissionsRepositoryForRole.perform(role_identifier, &block)) end end |
.inherits(permissions_class) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ingress/permissions.rb', line 12 def inherits() role_identifier = :dummy if @permissions_repository = .merge( Services::CopyPermissionsRepositoryIntoRole.perform(role_identifier, .), ) end end |
.permissions_repository ⇒ Object
8 9 10 |
# File 'lib/ingress/permissions.rb', line 8 def @permissions_repository ||= PermissionsRepository.new end |
Instance Method Details
#can?(action, subject) ⇒ Boolean
45 46 47 48 49 |
# File 'lib/ingress/permissions.rb', line 45 def can?(action, subject) find_matching_rules(action, subject).any? do |rule| rule.match?(action, subject, user) end end |
#user_role_identifiers ⇒ Object
51 52 53 |
# File 'lib/ingress/permissions.rb', line 51 def user_role_identifiers [] end |