Class: GraphQL::Define::DefinedObjectProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/define/defined_object_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ DefinedObjectProxy

Returns a new instance of DefinedObjectProxy


4
5
6
7
# File 'lib/graphql/define/defined_object_proxy.rb', line 4

def initialize(target)
  @target = target
  @dictionary = target.class.dictionary
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'lib/graphql/define/defined_object_proxy.rb', line 13

def method_missing(name, *args, &block)
  definition = @dictionary[name]
  if definition
    definition.call(@target, *args, &block)
  else
    p "Failed to find config #{name} in #{inspect}"
    super
  end
end

Instance Method Details

#inspectObject


27
28
29
# File 'lib/graphql/define/defined_object_proxy.rb', line 27

def inspect
  "<DefinedObjectProxy #{@target} (#{@dictionary.keys})>"
end

#to_sObject


23
24
25
# File 'lib/graphql/define/defined_object_proxy.rb', line 23

def to_s
  inspect
end

#typesObject


9
10
11
# File 'lib/graphql/define/defined_object_proxy.rb', line 9

def types
  GraphQL::Define::TypeDefiner.instance
end