Class: GraphQL::Api::Policy
- Inherits:
-
Object
- Object
- GraphQL::Api::Policy
- Defined in:
- lib/graphql/api/policy.rb
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #create? ⇒ Boolean
- #destroy? ⇒ Boolean
-
#initialize(ctx, model) ⇒ Policy
constructor
A new instance of Policy.
- #read? ⇒ Boolean
- #unauthorized! ⇒ Object
- #unauthorized_field_access(name) ⇒ Object
- #update? ⇒ Boolean
- #user ⇒ Object
Constructor Details
#initialize(ctx, model) ⇒ Policy
Returns a new instance of Policy.
7 8 9 10 |
# File 'lib/graphql/api/policy.rb', line 7 def initialize(ctx, model) @model = model @ctx = ctx end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
5 6 7 |
# File 'lib/graphql/api/policy.rb', line 5 def ctx @ctx end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
5 6 7 |
# File 'lib/graphql/api/policy.rb', line 5 def model @model end |
Instance Method Details
#create? ⇒ Boolean
16 17 18 |
# File 'lib/graphql/api/policy.rb', line 16 def create? true end |
#destroy? ⇒ Boolean
24 25 26 |
# File 'lib/graphql/api/policy.rb', line 24 def destroy? true end |
#read? ⇒ Boolean
28 29 30 |
# File 'lib/graphql/api/policy.rb', line 28 def read? true end |
#unauthorized! ⇒ Object
32 33 34 |
# File 'lib/graphql/api/policy.rb', line 32 def raise UnauthorizedException.new end |
#unauthorized_field_access(name) ⇒ Object
36 37 38 |
# File 'lib/graphql/api/policy.rb', line 36 def (name) nil end |
#update? ⇒ Boolean
20 21 22 |
# File 'lib/graphql/api/policy.rb', line 20 def update? true end |
#user ⇒ Object
12 13 14 |
# File 'lib/graphql/api/policy.rb', line 12 def user ctx[:current_user] end |