aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/row.rb
diff options
context:
space:
mode:
authorBryan Helmkamp <bryan@brynary.com>2009-05-17 15:42:42 -0400
committerBryan Helmkamp <bryan@brynary.com>2009-05-17 15:42:42 -0400
commit8339f024c7663133a78c4d0a8824b5b6fafaf239 (patch)
treea43ebc9c956d8484647d81e5ea14534e7b0570a0 /lib/arel/algebra/relations/row.rb
parent4c71e3b2ea4b8da574954cbd8a26d12f2cc640d0 (diff)
downloadrails-8339f024c7663133a78c4d0a8824b5b6fafaf239.tar.gz
rails-8339f024c7663133a78c4d0a8824b5b6fafaf239.tar.bz2
rails-8339f024c7663133a78c4d0a8824b5b6fafaf239.zip
recursive memory operations now possible
Conflicts: lib/arel/algebra/relations/relation.rb
Diffstat (limited to 'lib/arel/algebra/relations/row.rb')
-rw-r--r--lib/arel/algebra/relations/row.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/arel/algebra/relations/row.rb b/lib/arel/algebra/relations/row.rb
new file mode 100644
index 0000000000..2d63498452
--- /dev/null
+++ b/lib/arel/algebra/relations/row.rb
@@ -0,0 +1,21 @@
+module Arel
+ class Row
+ attributes :relation, :tuple
+ deriving :==, :initialize
+
+ def [](attribute)
+ tuple[relation.position_of(attribute)]
+ end
+
+ def slice(*attributes)
+ Row.new(relation, attributes.inject([]) do |cheese, attribute|
+ cheese << self[attribute]
+ cheese
+ end)
+ end
+
+ def bind(relation)
+ Row.new(relation, tuple)
+ end
+ end
+end \ No newline at end of file