class GraphQL::Define::DefinedObjectProxy
This allows a method-based DSL without adding methods to the defined class.
{@target} is passed to the specified function, along with any arguments and block.
This object delegates most methods to a dictionary of functions, {@dictionary}.
def initialize(target)
def initialize(target) @target = target @dictionary = target.class.dictionary end
def method_missing(name, *args, &block)
def method_missing(name, *args, &block) definition = @dictionary[name] if definition definition.call(@target, *args, &block) else msg = "#{@target.class.name} can't define '#{name}'" raise NoDefinitionError, msg, caller end end
def respond_to_missing?(name, include_private = false)
def respond_to_missing?(name, include_private = false) @dictionary[name] || super end
def types
def types GraphQL::Define::TypeDefiner.instance end
def use(plugin, **kwargs)
-
kwargs
(Hash
) -- Any options for the plugin -
plugin
(<#use(defn, **kwargs)>
) -- A plugin object
def use(plugin, **kwargs) # https://bugs.ruby-lang.org/issues/10708 if kwargs == {} plugin.use(self) else plugin.use(self, **kwargs) end end