Class: GraphQL::Schema::InstrumentedFieldMap

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/schema/instrumented_field_map.rb

Overview

A two-level map with fields as the last values. The first level is type names, which point to a second map. The second level is field names, which point to fields.

The catch is, the fields in this map may have been modified by being instrumented.

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ InstrumentedFieldMap


9
10
11
# File 'lib/graphql/schema/instrumented_field_map.rb', line 9

def initialize(schema)
  @storage = Hash.new { |h, k| h[k] = {} }
end

Instance Method Details

#get(type_name, field_name) ⇒ Object


17
18
19
20
# File 'lib/graphql/schema/instrumented_field_map.rb', line 17

def get(type_name, field_name)
  type = @storage[type_name]
  type && type[field_name]
end

#set(type_name, field_name, field) ⇒ Object


13
14
15
# File 'lib/graphql/schema/instrumented_field_map.rb', line 13

def set(type_name, field_name, field)
  @storage[type_name][field_name] = field
end