aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 15:17:10 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 15:19:42 -0700
commita60770d3bf3a8aeac16c110f3a7d05a6d52a86d6 (patch)
tree159a11b0566e67ce8730fbbcb17052f449434f15 /activerecord/lib/active_record/core.rb
parent35362817b16e97c9db07c5d2586a95009e747b28 (diff)
downloadrails-a60770d3bf3a8aeac16c110f3a7d05a6d52a86d6.tar.gz
rails-a60770d3bf3a8aeac16c110f3a7d05a6d52a86d6.tar.bz2
rails-a60770d3bf3a8aeac16c110f3a7d05a6d52a86d6.zip
Remove `klass` and `arel_table` as a dependency of `PredicateBuilder`
This class cares far too much about the internals of other parts of Active Record. This is an attempt to break out a meaningful object which represents the needs of the predicate builder. I'm not fully satisfied with the name, but the general concept is an object which represents a table, the associations to/from that table, and the types associated with it. Many of these exist at the `ActiveRecord::Base` class level, not as properties of the table itself, hence the need for another object. Currently it provides these by holding a reference to the class, but that will likely change in the future. This allows the predicate builder to remain wholy concerned with building predicates. /cc @mrgilman
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 65ca1f6fd3..cb53fb0d44 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -249,12 +249,12 @@ module ActiveRecord
end
def predicate_builder # :nodoc:
- @predicate_builder ||= PredicateBuilder.new(self, arel_table)
+ @predicate_builder ||= PredicateBuilder.new(table_metadata)
end
private
- def relation #:nodoc:
+ def relation # :nodoc:
relation = Relation.create(self, arel_table, predicate_builder)
if finder_needs_type_condition?
@@ -263,6 +263,10 @@ module ActiveRecord
relation
end
end
+
+ def table_metadata # :nodoc:
+ TableMetadata.new(self, arel_table)
+ end
end
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with