Sha256: 810cd11050577daf8bfdfa9b6bd85966c9da6fd65ddff3ba6ba20e83c9a72b8a

Contents?: true

Size: 603 Bytes

Versions: 3

Compression:

Stored size: 603 Bytes

Contents

module Arel
  class Row
    attr_reader :tuple, :relation

    def initialize relation, tuple
      @relation = relation
      @tuple = tuple
    end

    def [](attribute)
      attribute.type_cast(tuple[relation.position_of(attribute)])
    end

    def slice(*attributes)
      Row.new(relation, attributes.map do |attribute|
        # FIXME TESTME method chaining
        tuple[relation.relation.position_of(attribute)]
      end)
    end

    def bind(relation)
      Row.new(relation, tuple)
    end

    def combine(other, relation)
      Row.new(relation, tuple + other.tuple)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arel-1.0.1 lib/arel/algebra/relations/row.rb
arel-1.0.0 lib/arel/algebra/relations/row.rb
arel-1.0.0.rc1 lib/arel/algebra/relations/row.rb