Class: Rails::GraphQL::Source::ScopedConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails/graphql/source.rb

Overview

Helper class to be used as the self in configuration blocks

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, **xargs, &block) ⇒ Object



40
41
42
43
44
# File 'lib/rails/graphql/source.rb', line 40

def method_missing(method_name, *args, **xargs, &block)
  self_object.respond_to?(method_name, true) \
    ? self_object.send(method_name, *args, **xargs, &block) \
    : receiver.send(method_name, *args, **xargs, &block)
end

Instance Attribute Details

#receiverObject

Returns the value of attribute receiver

Returns:

  • (Object)

    the current value of receiver



29
30
31
# File 'lib/rails/graphql/source.rb', line 29

def receiver
  @receiver
end

#self_objectObject

Returns the value of attribute self_object

Returns:

  • (Object)

    the current value of self_object



29
30
31
# File 'lib/rails/graphql/source.rb', line 29

def self_object
  @self_object
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



29
30
31
# File 'lib/rails/graphql/source.rb', line 29

def type
  @type
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/rails/graphql/source.rb', line 35

def respond_to_missing?(method_name, include_private = false)
  self_object.respond_to?(method_name, include_private) ||
    receiver.respond_to?(method_name, include_private)
end

#safe_field(name, *args, **xargs, &block) ⇒ Object



30
31
32
33
# File 'lib/rails/graphql/source.rb', line 30

def safe_field(name, *args, **xargs, &block)
  return if receiver.send(:skip_field?, name, on: type)
  self_object.safe_field(name, *args, **xargs, &block)
end