Sha256: a745ab6441cc5b417c0802dd77b9bcb5dea3a2a59ba1accef1ae5de859b8f995
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
Contents
module Ecoportal module API class GraphQL class Fragment class << self def const?(value) begin const_get(value) rescue NameError => e return false end true end def fragment(sym, heredoc) fragments[sym] = heredoc end def fragments @fragments ||= {} end end attr_reader :client, :fragments def initialize(client) @client = client parse end private def parse fragments = self.class.fragments.each_with_object({}) do |(sym, heredoc), out| if self.class.const?(sym) fragment = self.class.get_const(sym) else fragment = client.parse(heredoc) self.class.const_set(sym, fragment) end out[sym] = fragment end end end end end end require 'ecoportal/api/graphql/fragment/contractor_entity' require 'ecoportal/api/graphql/fragment/pagination'
Version data entries
5 entries across 5 versions & 1 rubygems