Class: GraphQL::Api::Policy

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/api/policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#ctxObject (readonly)

Returns the value of attribute ctx.



5
6
7
# File 'lib/graphql/api/policy.rb', line 5

def ctx
  @ctx
end

#modelObject (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

Returns:

  • (Boolean)


16
17
18
# File 'lib/graphql/api/policy.rb', line 16

def create?
  true
end

#destroy?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/graphql/api/policy.rb', line 24

def destroy?
  true
end

#read?Boolean

Returns:

  • (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 unauthorized!
  raise UnauthorizedException.new
end

#unauthorized_field_access(name) ⇒ Object



36
37
38
# File 'lib/graphql/api/policy.rb', line 36

def unauthorized_field_access(name)
  nil
end

#update?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/graphql/api/policy.rb', line 20

def update?
  true
end

#userObject



12
13
14
# File 'lib/graphql/api/policy.rb', line 12

def user
  ctx[:current_user]
end