Class: GQLi::Fragment
Overview
Fragment wrapper
Instance Attribute Summary collapse
-
#__on_type ⇒ Object
readonly
Returns the value of attribute __on_type.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(name, on, &block) ⇒ Fragment
constructor
A new instance of Fragment.
-
#to_gql ⇒ Object
Serializes to a GraphQL string.
Methods inherited from Base
Constructor Details
#initialize(name, on, &block) ⇒ Fragment
Returns a new instance of Fragment
11 12 13 14 |
# File 'lib/gqli/fragment.rb', line 11 def initialize(name, on, &block) super(name, 0, &block) @__on_type = on end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GQLi::Base
Instance Attribute Details
#__on_type ⇒ Object (readonly)
Returns the value of attribute __on_type
9 10 11 |
# File 'lib/gqli/fragment.rb', line 9 def __on_type @__on_type end |
Instance Method Details
#to_gql ⇒ Object
Serializes to a GraphQL string
17 18 19 20 21 22 23 |
# File 'lib/gqli/fragment.rb', line 17 def to_gql <<~GQL fragment #{__name} on #{__on_type} { #{__nodes.map(&:to_gql).join("\n")} } GQL end |