Class: RailsIam::Authorization::AuthorizationRule
- Inherits:
-
Data
- Object
- Data
- RailsIam::Authorization::AuthorizationRule
- Defined in:
- app/services/rails_iam/authorization/authorization_rule.rb
Instance Attribute Summary collapse
-
#except ⇒ Object
readonly
Returns the value of attribute except.
-
#only ⇒ Object
readonly
Returns the value of attribute only.
-
#permission_match ⇒ Object
readonly
Returns the value of attribute permission_match.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#role_match ⇒ Object
readonly
Returns the value of attribute role_match.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #authorizer_arguments(inferred_permission: nil) ⇒ Object
- #matches?(action) ⇒ Boolean
- #valid? ⇒ Boolean
Instance Attribute Details
#except ⇒ Object (readonly)
Returns the value of attribute except
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def except @except end |
#only ⇒ Object (readonly)
Returns the value of attribute only
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def only @only end |
#permission_match ⇒ Object (readonly)
Returns the value of attribute permission_match
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def @permission_match end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def @permissions end |
#role_match ⇒ Object (readonly)
Returns the value of attribute role_match
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def role_match @role_match end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles
5 6 7 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 5 def roles @roles end |
Instance Method Details
#authorizer_arguments(inferred_permission: nil) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 23 def (inferred_permission: nil) { required_roles: roles, required_permissions: , inferred_permission: , role_match: role_match, permission_match: , } end |
#matches?(action) ⇒ Boolean
13 14 15 16 17 18 19 20 21 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 13 def matches?(action) action = action.to_sym return Array(only).map(&:to_sym).include?(action) if only.present? return Array(except).map(&:to_sym).exclude?(action) if except.present? true end |
#valid? ⇒ Boolean
33 34 35 |
# File 'app/services/rails_iam/authorization/authorization_rule.rb', line 33 def valid? roles.any? || .any? end |