aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/array.rb
blob: dac65abbc2228d06d92b4042429871badc2961cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Arel
  class Array < Relation
    include Recursion::BaseCase

    def initialize(array, attribute_names)
      @array, @attribute_names = array, attribute_names
    end

    def attributes
      @attributes ||= @attribute_names.collect do |name|
        Attribute.new(self, name.to_sym)
      end
    end

    def call(connection = nil)
      @array.collect { |row| attributes.zip(row).to_hash }
    end
  end
end