Sha256: d3795137d94a3847cb366fffca11db76b1aa3084893ceec889d620181cb0ce52

Contents?: true

Size: 996 Bytes

Versions: 2

Compression:

Stored size: 996 Bytes

Contents

module Ecoportal
  module API
    class GraphQL
      module Base
        class QueryArray < Ecoportal::API::GraphQL::Base::Query
          include Enumerable

          def each(item_block: nil, **kargs, &block)
            return to_enum(:each, **kargs, item_block: connection_block) unless block
            query(**kargs, &item_block).each do |item|
              yield(item) if block_given?
            end
          end

          def response_class
            return array_class if respond_to?(:array_class)
            @response_class ||= self.class.new_class(
              item_class,
              inherits: Ecoportal::API::Common::Content::CollectionModel
            ) do |klass|
              klass.klass = item_class
            end
          end

          private

          def basic_block
            raise "Missuse. You have to implement 'basic_block' private method in the child class"
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.1.11 lib/ecoportal/api/graphql/base/query_array.rb
ecoportal-api-graphql-0.1.10 lib/ecoportal/api/graphql/base/query_array.rb