Module: GraphQL::Schema::AcceptsDefinition::AcceptsDefinitionDefinitionMethods
- Defined in:
- lib/graphql/schema/member.rb
Instance Method Summary collapse
- #accepts_definition(name) ⇒ Object
- #accepts_definition_methods ⇒ Object
- #own_accepts_definition_methods ⇒ Object
Instance Method Details
#accepts_definition(name) ⇒ Object
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 94 95 96 97 98 |
# File 'lib/graphql/schema/member.rb', line 68 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_methods ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/graphql/schema/member.rb', line 100 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_methods ⇒ Object
118 119 120 |
# File 'lib/graphql/schema/member.rb', line 118 def own_accepts_definition_methods @own_accepts_definition_methods ||= [] end |