Class: Ecoportal::API::GraphQL::Fragment
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Fragment
- Includes:
- Common::GraphQL::ClassHelpers
- Defined in:
- lib/ecoportal/api/graphql/fragment.rb,
lib/ecoportal/api/graphql/fragment/action.rb,
lib/ecoportal/api/graphql/fragment/pagination.rb,
lib/ecoportal/api/graphql/fragment/location_node.rb,
lib/ecoportal/api/graphql/fragment/contractor_entity.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
Class Method Summary collapse
Instance Method Summary collapse
- #define(sym, heredoc, namespace: ::Fragment) ⇒ Object
-
#initialize(client) ⇒ Fragment
constructor
A new instance of Fragment.
Constructor Details
#initialize(client) ⇒ Fragment
Returns a new instance of Fragment.
24 25 26 27 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 24 def initialize(client) @client = client parse end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
22 23 24 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 22 def client @client end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
22 23 24 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 22 def fragments @fragments end |
Class Method Details
.fragment(sym, heredoc) ⇒ Object
13 14 15 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 13 def fragment(sym, heredoc) fragments[sym] = heredoc end |
.fragments ⇒ Object
17 18 19 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 17 def fragments @fragments ||= {} end |
Instance Method Details
#define(sym, heredoc, namespace: ::Fragment) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 29 def define(sym, heredoc, namespace: ::Fragment) namespace.send(:remove_const, sym) if namespace.const_defined?(sym) client.parse(heredoc).tap do |fragment| without_warnings do namespace.const_set(sym, fragment) ::Fragment.const_set(sym, fragment) unless namespace == ::Fragment end end end |