aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/active_relation/extensions/hash.rb8
-rw-r--r--lib/active_relation/predicates.rb10
-rw-r--r--lib/active_relation/primitives/attribute.rb4
-rw-r--r--lib/active_relation/primitives/value.rb4
-rw-r--r--lib/active_relation/relations/aggregation.rb4
-rw-r--r--lib/active_relation/relations/alias.rb4
-rw-r--r--lib/active_relation/relations/compound.rb4
-rw-r--r--lib/active_relation/relations/join.rb8
-rw-r--r--lib/active_relation/relations/order.rb4
-rw-r--r--lib/active_relation/relations/projection.rb4
-rw-r--r--lib/active_relation/relations/rename.rb4
-rw-r--r--lib/active_relation/relations/selection.rb4
-rw-r--r--lib/active_relation/relations/skip.rb4
-rw-r--r--lib/active_relation/relations/table.rb8
-rw-r--r--lib/active_relation/relations/take.rb4
15 files changed, 3 insertions, 75 deletions
diff --git a/lib/active_relation/extensions/hash.rb b/lib/active_relation/extensions/hash.rb
index a33ace5738..7472b5aa73 100644
--- a/lib/active_relation/extensions/hash.rb
+++ b/lib/active_relation/extensions/hash.rb
@@ -1,11 +1,7 @@
class Hash
def bind(relation)
- descend { |x| x.bind(relation) }
- end
-
- def descend(&block)
- inject({}) do |descendent, (key, value)|
- descendent.merge(yield(key) => yield(value))
+ inject({}) do |bound, (key, value)|
+ bound.merge(key.bind(relation) => value.bind(relation))
end
end
end \ No newline at end of file
diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb
index dc4610b052..2cab1721d0 100644
--- a/lib/active_relation/predicates.rb
+++ b/lib/active_relation/predicates.rb
@@ -17,20 +17,12 @@ module ActiveRelation
end
def bind(relation)
- descend { |x| x.bind(relation) }
+ self.class.new(operand1.bind(relation), operand2.bind(relation))
end
- def qualify
- descend(&:qualify)
- end
-
def to_sql(formatter = nil)
"#{operand1.to_sql} #{predicate_sql} #{operand1.format(operand2)}"
end
-
- def descend
- self.class.new(yield(operand1), yield(operand2))
- end
end
class Equality < Binary
diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb
index 9685d2ab4a..d815656794 100644
--- a/lib/active_relation/primitives/attribute.rb
+++ b/lib/active_relation/primitives/attribute.rb
@@ -20,10 +20,6 @@ module ActiveRelation
relation == new_relation ? self : Attribute.new(new_relation, name, :alias => @alias, :ancestor => self)
end
- def qualify
- self.as(qualified_name)
- end
-
def to_attribute
self
end
diff --git a/lib/active_relation/primitives/value.rb b/lib/active_relation/primitives/value.rb
index 3fbe907324..9042aea067 100644
--- a/lib/active_relation/primitives/value.rb
+++ b/lib/active_relation/primitives/value.rb
@@ -20,10 +20,6 @@ module ActiveRelation
value == other.value
end
- def qualify
- self
- end
-
def bind(relation)
Value.new(value, relation)
end
diff --git a/lib/active_relation/relations/aggregation.rb b/lib/active_relation/relations/aggregation.rb
index 38f1f2dda8..62432408e1 100644
--- a/lib/active_relation/relations/aggregation.rb
+++ b/lib/active_relation/relations/aggregation.rb
@@ -20,9 +20,5 @@ module ActiveRelation
def aggregation?
true
end
-
- def descend(&block)
- Aggregation.new(relation.descend(&block), :expressions => expressions.collect(&block), :groupings => groupings.collect(&block))
- end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/alias.rb b/lib/active_relation/relations/alias.rb
index f24b1d743c..cf410c6462 100644
--- a/lib/active_relation/relations/alias.rb
+++ b/lib/active_relation/relations/alias.rb
@@ -9,10 +9,6 @@ module ActiveRelation
def alias?
true
end
-
- def descend(&block)
- Alias.new(relation.descend(&block), @alias)
- end
def ==(other)
self.class == other.class and
diff --git a/lib/active_relation/relations/compound.rb b/lib/active_relation/relations/compound.rb
index aa3274cbd3..7c84482115 100644
--- a/lib/active_relation/relations/compound.rb
+++ b/lib/active_relation/relations/compound.rb
@@ -12,9 +12,5 @@ module ActiveRelation
def attributes
relation.attributes.collect { |a| a.bind(self) }
end
-
- def qualify
- descend(&:qualify)
- end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/join.rb b/lib/active_relation/relations/join.rb
index c5ce47b555..dbcb520b92 100644
--- a/lib/active_relation/relations/join.rb
+++ b/lib/active_relation/relations/join.rb
@@ -18,10 +18,6 @@ module ActiveRelation
)
end
- def qualify
- descend(&:qualify)
- end
-
def attributes
(externalize(relation1).attributes +
externalize(relation2).attributes).collect { |a| a.bind(self) }
@@ -31,10 +27,6 @@ module ActiveRelation
externalize(relation1).prefix_for(attribute) or
externalize(relation2).prefix_for(attribute)
end
-
- def descend(&block)
- Join.new(join_sql, relation1.descend(&block), relation2.descend(&block), *predicates.collect(&block))
- end
def joins
this_join = [
diff --git a/lib/active_relation/relations/order.rb b/lib/active_relation/relations/order.rb
index d71ff09c41..b5495fad67 100644
--- a/lib/active_relation/relations/order.rb
+++ b/lib/active_relation/relations/order.rb
@@ -13,10 +13,6 @@ module ActiveRelation
relation == other.relation and
ordering == other.ordering
end
-
- def descend(&block)
- Order.new(relation.descend(&block), yield(ordering))
- end
def orders
relation.orders + [ordering]
diff --git a/lib/active_relation/relations/projection.rb b/lib/active_relation/relations/projection.rb
index c478ae145f..c1495c1742 100644
--- a/lib/active_relation/relations/projection.rb
+++ b/lib/active_relation/relations/projection.rb
@@ -15,9 +15,5 @@ module ActiveRelation
relation == other.relation and
projections == other.projections
end
-
- def descend(&block)
- Projection.new(relation.descend(&block), *projections.collect(&block))
- end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/rename.rb b/lib/active_relation/relations/rename.rb
index ac5484bfff..9ab07707a0 100644
--- a/lib/active_relation/relations/rename.rb
+++ b/lib/active_relation/relations/rename.rb
@@ -18,10 +18,6 @@ module ActiveRelation
relation.attributes.collect(&method(:christen))
end
- def descend(&block)
- Rename.new(relation.descend(&block), yield(attribute) => pseudonym)
- end
-
private
def christen(attribute)
(attribute =~ self.attribute ? attribute.as(pseudonym) : attribute).bind(self) rescue nil
diff --git a/lib/active_relation/relations/selection.rb b/lib/active_relation/relations/selection.rb
index 032de63d04..fb90405b01 100644
--- a/lib/active_relation/relations/selection.rb
+++ b/lib/active_relation/relations/selection.rb
@@ -14,10 +14,6 @@ module ActiveRelation
predicate == other.predicate
end
- def descend(&block)
- Selection.new(relation.descend(&block), yield(predicate))
- end
-
def selects
relation.selects + [predicate]
end
diff --git a/lib/active_relation/relations/skip.rb b/lib/active_relation/relations/skip.rb
index 3133a3af41..5973dff8b9 100644
--- a/lib/active_relation/relations/skip.rb
+++ b/lib/active_relation/relations/skip.rb
@@ -11,9 +11,5 @@ module ActiveRelation
relation == other.relation and
skipped == other.skipped
end
-
- def descend(&block)
- Skip.new(relation.descend(&block), skipped)
- end
end
end \ No newline at end of file
diff --git a/lib/active_relation/relations/table.rb b/lib/active_relation/relations/table.rb
index 5ad27c1fcf..e645f71030 100644
--- a/lib/active_relation/relations/table.rb
+++ b/lib/active_relation/relations/table.rb
@@ -15,10 +15,6 @@ module ActiveRelation
end
end
- def qualify
- Rename.new self, qualifications
- end
-
def prefix_for(attribute)
self[attribute] and name
end
@@ -36,10 +32,6 @@ module ActiveRelation
@columns ||= engine.columns(name, "#{name} Columns")
end
- def descend
- yield self
- end
-
def reset
@attributes = @columns = nil
end
diff --git a/lib/active_relation/relations/take.rb b/lib/active_relation/relations/take.rb
index 02d507753d..d9d439b3f5 100644
--- a/lib/active_relation/relations/take.rb
+++ b/lib/active_relation/relations/take.rb
@@ -11,9 +11,5 @@ module ActiveRelation
relation == other.relation and
taken == other.taken
end
-
- def descend(&block)
- Take.new(relation.descend(&block), taken)
- end
end
end \ No newline at end of file