aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/array.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/relations/array.rb')
-rw-r--r--lib/arel/relations/array.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/arel/relations/array.rb b/lib/arel/relations/array.rb
new file mode 100644
index 0000000000..dac65abbc2
--- /dev/null
+++ b/lib/arel/relations/array.rb
@@ -0,0 +1,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 \ No newline at end of file