aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-12-26 14:17:22 -0700
committerSean Griffin <sean@thoughtbot.com>2014-12-26 14:18:26 -0700
commit392a453b10abad60432f2612000f306de55b7d1a (patch)
tree32d3216bacb4c51e1f1d112b3f4cdac590e3973c /activerecord/lib/active_record/relation/predicate_builder.rb
parenta3936bbe21f4bff8247f890cacfd0fc882921003 (diff)
downloadrails-392a453b10abad60432f2612000f306de55b7d1a.tar.gz
rails-392a453b10abad60432f2612000f306de55b7d1a.tar.bz2
rails-392a453b10abad60432f2612000f306de55b7d1a.zip
Re-use the predicate builder in the `ArrayHandler`
This reduces the number of places which will need to care about single value or range specific logic as we introduce type casting. The array handler is only responsible for producing `in` statements. /cc @mrgilman [Sean Griffin & Melanie Gilman]
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder.rb')
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 71bb795d5b..61db27d150 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -17,7 +17,7 @@ module ActiveRecord
register_handler(Base, BaseHandler.new)
register_handler(Range, RangeHandler.new)
register_handler(Relation, RelationHandler.new)
- register_handler(Array, ArrayHandler.new)
+ register_handler(Array, ArrayHandler.new(self))
end
def resolve_column_aliases(hash)
@@ -93,6 +93,10 @@ module ActiveRecord
@handlers.unshift([klass, handler])
end
+ def build(attribute, value)
+ handler_for(value).call(attribute, value)
+ end
+
protected
attr_reader :klass, :table
@@ -129,10 +133,6 @@ module ActiveRecord
attributes
end
- def build(attribute, value)
- handler_for(value).call(attribute, value)
- end
-
def handler_for(object)
@handlers.detect { |klass, _| klass === object }.last
end