aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations
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
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')
-rw-r--r--lib/arel/algebra/relations/relation.rb4
-rw-r--r--lib/arel/algebra/relations/row.rb21
2 files changed, 21 insertions, 4 deletions
diff --git a/lib/arel/algebra/relations/relation.rb b/lib/arel/algebra/relations/relation.rb
index 6d76e66638..fe8cab4b02 100644
--- a/lib/arel/algebra/relations/relation.rb
+++ b/lib/arel/algebra/relations/relation.rb
@@ -14,10 +14,6 @@ module Arel
self
end
- def root
- self
- end
-
module Enumerable
include ::Enumerable
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