Sha256: 2ec0d95af528333b3c57428ba6aeff942cc7c115b4b12bfced75afd8261e5af7

Contents?: true

Size: 635 Bytes

Versions: 11

Compression:

Stored size: 635 Bytes

Contents

module Neo4j
  module Core
    class Result
      attr_reader :columns, :rows

      def initialize(columns, rows)
        @columns = columns.map(&:to_sym)
        @rows = rows
        @struct_class = Struct.new(:index, *@columns)
      end

      include Enumerable

      def each
        structs.each do |struct|
          yield struct
        end
      end

      def structs
        @structs ||= rows.each_with_index.map do |row, index|
          @struct_class.new(index, *row)
        end
      end

      def hashes
        @hashes ||= rows.map do |row|
          Hash[@columns.zip(row)]
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
activegraph-10.0.0.pre.alpha.11 lib/neo4j/core/result.rb
activegraph-10.0.0.pre.alpha.10 lib/neo4j/core/result.rb
activegraph-10.0.0.pre.alpha.9 lib/neo4j/core/result.rb
activegraph-10.0.0.pre.alpha.8 lib/neo4j/core/result.rb
activegraph-10.0.0.pre.alpha.7 lib/neo4j/core/result.rb
activegraph-10.0.0.pre.alpha.6 lib/neo4j/core/result.rb
neo4j-10.0.0.pre.alpha.5 lib/neo4j/core/result.rb
neo4j-10.0.0.pre.alpha.4 lib/neo4j/core/result.rb
neo4j-10.0.0.pre.alpha.3 lib/neo4j/core/result.rb
neo4j-10.0.0.pre.alpha.2 lib/neo4j/core/result.rb
neo4j-10.0.0.pre.alpha.1 lib/neo4j/core/result.rb