diff options
author | Carl Lerche <carllerche@mac.com> | 2010-03-12 12:51:20 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-03-12 12:52:07 -0800 |
commit | 83c27c0b5e2e341307b7a160d831fb930a9552b4 (patch) | |
tree | fc41004d425cbc9827e82f550959ed40e8c12978 /lib/arel/engines/memory | |
parent | 602722922c8365afcb3e9bed3721d61756322353 (diff) | |
download | rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.tar.gz rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.tar.bz2 rails-83c27c0b5e2e341307b7a160d831fb930a9552b4.zip |
Attributes should be typed
Diffstat (limited to 'lib/arel/engines/memory')
-rw-r--r-- | lib/arel/engines/memory/relations/array.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/arel/engines/memory/relations/array.rb b/lib/arel/engines/memory/relations/array.rb index 5e7c0a4ab1..577e327b19 100644 --- a/lib/arel/engines/memory/relations/array.rb +++ b/lib/arel/engines/memory/relations/array.rb @@ -1,16 +1,21 @@ module Arel class Array < Relation - attributes :array, :attribute_names + attributes :array, :attribute_names_and_types include Recursion::BaseCase deriving :==, :initialize + def initialize(array, attribute_names_and_types) + @array, @attribute_names_and_types = array, attribute_names_and_types + end + def engine @engine ||= Memory::Engine.new end def attributes - @attributes ||= @attribute_names.collect do |name| - name.to_attribute(self) + @attributes ||= @attribute_names_and_types.collect do |attribute, type| + attribute = type.new(self, attribute) if Symbol === attribute + attribute end end |