Module: Ecoportal::API::GraphQL::Concerns::FragmentDefinitions::InstanceMethods
- Defined in:
- lib/ecoportal/api/graphql/concerns/fragment_definitions.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#fragments ⇒ Object
readonly
Returns the value of attribute fragments.
Instance Method Summary collapse
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
30 31 32 |
# File 'lib/ecoportal/api/graphql/concerns/fragment_definitions.rb', line 30 def client @client end |
#fragments ⇒ Object (readonly)
Returns the value of attribute fragments.
30 31 32 |
# File 'lib/ecoportal/api/graphql/concerns/fragment_definitions.rb', line 30 def fragments @fragments end |
Instance Method Details
#define(sym, heredoc, namespace: ::Fragment) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ecoportal/api/graphql/concerns/fragment_definitions.rb', line 37 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) end end rescue ::GraphQL::Client::ValidationError, ::Graphlient::Errors::ClientError => err raise err.class, "On fragment #{sym} -- #{err.}", cause: nil end |
#initialize(client) ⇒ Object
32 33 34 35 |
# File 'lib/ecoportal/api/graphql/concerns/fragment_definitions.rb', line 32 def initialize(client) @client = client parse end |