Module: GraphQL::Schema::Member::AcceptsDefinition::AcceptsDefinitionDefinitionMethods Private

Defined in:
lib/graphql/schema/member/accepts_definition.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#accepts_definition(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/graphql/schema/member/accepts_definition.rb', line 63

def accepts_definition(name)
  own_accepts_definition_methods << name

  ivar_name = "@#{name}_args"
  if self.is_a?(Class)
    define_singleton_method(name) do |*args|
      if args.any?
        instance_variable_set(ivar_name, args)
      end
      instance_variable_get(ivar_name) || (superclass.respond_to?(name) ? superclass.public_send(name) : nil)
    end

    define_method(name) do |*args|
      if args.any?
        instance_variable_set(ivar_name, args)
      end
      instance_variable_get(ivar_name)
    end
  else
    # Special handling for interfaces, define it here
    # so it's appropriately passed down
    self::DefinitionMethods.module_eval do
      define_method(name) do |*args|
        if args.any?
          instance_variable_set(ivar_name, args)
        end
        instance_variable_get(ivar_name) || ((int = interfaces.first { |i| i.respond_to?()}) && int.public_send(name))
      end
    end
  end
end

#accepts_definition_methodsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/graphql/schema/member/accepts_definition.rb', line 95

def accepts_definition_methods
  inherited_methods = if self.is_a?(Class)
    superclass.respond_to?(:accepts_definition_methods) ? superclass.accepts_definition_methods : []
  elsif self.is_a?(Module)
    m = []
    ancestors.each do |a|
      if a.respond_to?(:own_accepts_definition_methods)
        m.concat(a.own_accepts_definition_methods)
      end
    end
    m
  else
    self.class.accepts_definition_methods
  end

  own_accepts_definition_methods + inherited_methods
end

#own_accepts_definition_methodsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


113
114
115
# File 'lib/graphql/schema/member/accepts_definition.rb', line 113

def own_accepts_definition_methods
  @own_accepts_definition_methods ||= []
end