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/location_draft.rb,
lib/ecoportal/api/graphql/fragment/action_category.rb,
lib/ecoportal/api/graphql/fragment/locations_error.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.
25 26 27 28 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 25 def initialize(client) @client = client parse end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 23 def client @client end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
23 24 25 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 23 def fragments @fragments end |
Class Method Details
.fragment(sym, heredoc) ⇒ Object
14 15 16 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 14 def fragment(sym, heredoc) fragments[sym] = heredoc end |
.fragments ⇒ Object
18 19 20 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 18 def fragments @fragments ||= {} end |
Instance Method Details
#define(sym, heredoc, namespace: ::Fragment) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ecoportal/api/graphql/fragment.rb', line 30 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 rescue ::GraphQL::Client::ValidationError, ::Graphlient::Errors::ClientError => err raise err.class, "On fragment #{sym} -- #{err.}", cause: nil end |