Class: KittyPolicy::GraphQL::FieldAuthorization

Inherits:
Object
  • Object
show all
Defined in:
lib/kitty_policy/graphql/field_authorization.rb

Instance Method Summary collapse

Constructor Details

#initialize(policy:, current_user_key: :current_user) ⇒ FieldAuthorization

Returns a new instance of FieldAuthorization.



6
7
8
9
# File 'lib/kitty_policy/graphql/field_authorization.rb', line 6

def initialize(policy:, current_user_key: :current_user)
  @policy = policy
  @current_user_key = current_user_key
end

Instance Method Details

#instrument(_type, field) ⇒ Object



11
12
13
14
15
16
# File 'lib/kitty_policy/graphql/field_authorization.rb', line 11

def instrument(_type, field)
  return instrument_with_authorize(field) if field..key?(:authorize)
  return instrument_with_authorize_object(field) if field..key?(:authorize_object)

  field
end