Class: GQLi::Node
Overview
Node wrapper
Instance Attribute Summary collapse
-
#__params ⇒ Object
readonly
Returns the value of attribute __params.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(name, params = {}, depth = 1, &block) ⇒ Node
constructor
A new instance of Node.
-
#to_gql ⇒ Object
Serializes to a GraphQL string.
Methods inherited from Base
Constructor Details
#initialize(name, params = {}, depth = 1, &block) ⇒ Node
Returns a new instance of Node.
10 11 12 13 |
# File 'lib/gqli/node.rb', line 10 def initialize(name, params = {}, depth = 1, &block) super(name, depth, &block) @__params = params end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GQLi::Base
Instance Attribute Details
#__params ⇒ Object (readonly)
Returns the value of attribute __params.
8 9 10 |
# File 'lib/gqli/node.rb', line 8 def __params @__params end |
Instance Method Details
#to_gql ⇒ Object
Serializes to a GraphQL string
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gqli/node.rb', line 16 def to_gql result = ' ' * __depth + __name result += __params_to_s(__params, true) unless __params.empty? unless __nodes.empty? result += " {\n" result += __nodes.map(&:to_gql).join("\n") result += "\n#{' ' * __depth}}" end result end |