Class: GraphQLIncludable::Relay::EdgeWithNode

Inherits:
GraphQL::Relay::Edge
  • Object
show all
Defined in:
lib/graphql_includable/relay/edge_with_node.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, connection) ⇒ EdgeWithNode

Returns a new instance of EdgeWithNode.



22
23
24
25
26
# File 'lib/graphql_includable/relay/edge_with_node.rb', line 22

def initialize(node, connection)
  @edge = node
  @edge_to_node = ->() { connection.edge_to_node(@edge) }
  super(nil, connection)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



33
34
35
36
37
38
39
# File 'lib/graphql_includable/relay/edge_with_node.rb', line 33

def method_missing(method_name, *args, &block)
  if @edge.respond_to?(method_name)
    @edge.send(method_name, *args, &block)
  else
    super
  end
end

Instance Method Details

#nodeObject



28
29
30
31
# File 'lib/graphql_includable/relay/edge_with_node.rb', line 28

def node
  @node ||= @edge_to_node.call
  @node
end

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

Returns:

  • (Boolean)


41
42
43
# File 'lib/graphql_includable/relay/edge_with_node.rb', line 41

def respond_to_missing?(method_name, include_private = false)
  @edge.respond_to?(method_name) || super
end