Module: Masks::Scoped
- Included in:
- Actor, Rails::Key, Rails::OpenID::AccessToken, Rails::OpenID::Client
- Defined in:
- app/models/concerns/masks/scoped.rb
Overview
A smaller interface that all scoped actors should adhere to.
Instance Method Summary collapse
-
#role?(record, **opts) ⇒ Boolean
Returns whether or not a role is available to the scoped actor.
-
#role_records(record_type, **opts) ⇒ Object
Similar to roles_for, except all records are returned instead of the role.
-
#roles(record, **opts) ⇒ Masks::Role
Returns a list of Masks::Role records for the scoped actor.
-
#scope?(scope) ⇒ Boolean
Returns whether or not a scope is available.
-
#scopes ⇒ Array<String>
Returns a list of scopes granted to the actor.
Instance Method Details
#role?(record, **opts) ⇒ Boolean
Returns whether or not a role is available to the scoped actor.
41 42 43 |
# File 'app/models/concerns/masks/scoped.rb', line 41 def role?(record, **opts) roles(record, **opts).any? end |
#role_records(record_type, **opts) ⇒ Object
Similar to roles_for, except all records are returned instead of the role.
50 51 52 |
# File 'app/models/concerns/masks/scoped.rb', line 50 def role_records(record_type, **opts) roles(record_type, **opts).map(&:record).uniq end |
#roles(record, **opts) ⇒ Masks::Role
Returns a list of Masks::Role records for the scoped actor.
32 33 34 |
# File 'app/models/concerns/masks/scoped.rb', line 32 def roles(record, **opts) raise NotImplementedError end |
#scope?(scope) ⇒ Boolean
Returns whether or not a scope is available.
In practice this is similar to calling scopes.include?(scope), but implementations may provide faster implementations.
23 24 25 |
# File 'app/models/concerns/masks/scoped.rb', line 23 def scope?(scope) scopes.include?(scope.to_s) end |
#scopes ⇒ Array<String>
Returns a list of scopes granted to the actor.
12 13 14 |
# File 'app/models/concerns/masks/scoped.rb', line 12 def scopes raise NotImplementedError end |