Sha256: dda2eede49131d02e69005faeea513a853c6d227c0bd52c0395692ff3ae3b820

Contents?: true

Size: 998 Bytes

Versions: 9

Compression:

Stored size: 998 Bytes

Contents

module Ecoportal
  module API
    class GraphQL
      module Logic
        class QueryArray < Ecoportal::API::GraphQL::Logic::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

9 entries across 9 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.8 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.3.7 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.3.6 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.3.5 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.3.3 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.3.1 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.2.3 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.2.2 lib/ecoportal/api/graphql/logic/query_array.rb
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/graphql/logic/query_array.rb