Class: Object

Inherits:
BasicObject
Defined in:
lib/okay/graphql.rb

Overview

:nodoc: rubocop:disable all

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/okay/graphql.rb', line 123

def self.const_missing(name)
  # HACK: if const_missing is called inside Okay::GraphQL#initialize,
  #       we wrap the constant name in a GraphQL::Container.
  #       Otherwise, we re-raise the exception.
  if caller[2] =~ /^#{Regexp.escape(__FILE__)}:\d+:in `initialize'$/
    Okay::GraphQL::Container.new(name.to_s)
  else
    # Create an exception equivalent to what's normally raised.
    exception = NameError.new("uninitialized constant #{name.to_s}")

    # Preserve the backtrace.
    exception.set_backtrace(caller)

    # Raise the exception.
    raise exception
  end
end