Sha256: 5e2787e01d586a1c961a725df7532a41bc9f6bb532705636aff76a9c3d722371

Contents?: true

Size: 880 Bytes

Versions: 14

Compression:

Stored size: 880 Bytes

Contents

module Ecoportal
  module API
    class GraphQL
      module Logic
        class Connection < Ecoportal::API::GraphQL::Base::Model
          class GenericNode
            def initialize(*args, **kargs)
              raise "Missuse error. You should define a node_class for a class that inherits from GraphqlConnection class."
            end
          end

          include Enumerable

          class_resolver :node_class, GenericNode

          passthrough :edges
          passthrough :totalCount
          embeds_many :nodes, klass: :node_class
          embeds_one :pageInfo, klass: Ecoportal::API::GraphQL::Base::PageInfo

          def empty?
            count < 1
          end

          def each(&block)
            return to_enum(:each) unless block
            nodes.each(&block)
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.13 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.12 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.11 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.10 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.9 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.8 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.7 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.6 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.5 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.3 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.3.1 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.2.3 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.2.2 lib/ecoportal/api/graphql/logic/connection.rb
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/graphql/logic/connection.rb