Class: GQL::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/gql/config.rb

Instance Method Summary collapse

Instance Method Details

#debugObject



68
69
70
71
72
73
74
75
# File 'lib/gql/config.rb', line 68

def debug
  if defined? @@debug
    @@debug
  else
    @@debug = nil
    self.debug = ENV.has_key?('DEBUG')
  end
end

#debug=(value) ⇒ Object



77
78
79
80
81
82
83
84
85
# File 'lib/gql/config.rb', line 77

def debug=(value)
  value = !!value

  return if value == @@debug

  value ? switch_debug_on : switch_debug_off

  @@debug = value
end

#default_call_procObject



60
61
62
# File 'lib/gql/config.rb', line 60

def default_call_proc
  @@default_call_proc ||= -> id { -> (*args) { target.public_send(id, *args) } }
end

#default_call_proc=(value) ⇒ Object



64
65
66
# File 'lib/gql/config.rb', line 64

def default_call_proc=(value)
  @@default_call_proc = value
end

#default_field_procObject



52
53
54
# File 'lib/gql/config.rb', line 52

def default_field_proc
  @@default_field_proc ||= -> id { -> { target.public_send(id) } }
end

#default_field_proc=(value) ⇒ Object



56
57
58
# File 'lib/gql/config.rb', line 56

def default_field_proc=(value)
  @@default_field_proc = value
end

#default_list_classObject



40
41
42
# File 'lib/gql/config.rb', line 40

def default_list_class
  @@default_list_class ||= Node
end

#default_list_class=(value) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/gql/config.rb', line 44

def default_list_class=(value)
  unless value.nil? || value <= Node
    raise Errors::InvalidNodeClass.new(value, Node)
  end

  @@default_list_class = value
end

#field_typesObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/gql/config.rb', line 25

def field_types
  @@field_types ||= {
    array:      Array,
    boolean:    Boolean,
    connection: Connection,
    number:     Number,
    object:     Object,
    string:     String
  }
end

#field_types=(value) ⇒ Object



36
37
38
# File 'lib/gql/config.rb', line 36

def field_types=(value)
  @@field_types = value
end

#root_node_classObject



5
6
7
# File 'lib/gql/config.rb', line 5

def root_node_class
  @@root_node_class ||= nil
end

#root_node_class=(value) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/gql/config.rb', line 9

def root_node_class=(value)
  unless value.nil? || value <= Node
    raise Errors::InvalidNodeClass.new(value, Node)
  end

  @@root_node_class = value
end

#root_target_procObject



17
18
19
# File 'lib/gql/config.rb', line 17

def root_target_proc
  @@root_target_proc ||= -> context { nil }
end

#root_target_proc=(value) ⇒ Object



21
22
23
# File 'lib/gql/config.rb', line 21

def root_target_proc=(value)
  @@root_target_proc = value
end