aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-10-03 14:12:06 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-10-03 14:40:06 -0700
commit83633b807a3b08aaf5554c0fc793583a064c2472 (patch)
tree7f9e76582a610c3fed8ab380d9a4a5b99b5551a8 /activerecord/lib/active_record/relation/predicate_builder.rb
parent18a7b767e8ad545702c1025fc9cc7a1cc3c64f28 (diff)
downloadrails-83633b807a3b08aaf5554c0fc793583a064c2472.tar.gz
rails-83633b807a3b08aaf5554c0fc793583a064c2472.tar.bz2
rails-83633b807a3b08aaf5554c0fc793583a064c2472.zip
avoid creating objects when we can
Diffstat (limited to 'activerecord/lib/active_record/relation/predicate_builder.rb')
-rw-r--r--activerecord/lib/active_record/relation/predicate_builder.rb16
1 files changed, 5 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/relation/predicate_builder.rb b/activerecord/lib/active_record/relation/predicate_builder.rb
index 0d1307d87e..c5428dccd6 100644
--- a/activerecord/lib/active_record/relation/predicate_builder.rb
+++ b/activerecord/lib/active_record/relation/predicate_builder.rb
@@ -1,23 +1,18 @@
module ActiveRecord
- class PredicateBuilder
-
- def initialize(engine)
- @engine = engine
- end
-
- def build_from_hash(attributes, default_table)
+ class PredicateBuilder # :nodoc:
+ def self.build_from_hash(engine, attributes, default_table)
predicates = attributes.map do |column, value|
table = default_table
if value.is_a?(Hash)
- table = Arel::Table.new(column, :engine => @engine)
- build_from_hash(value, table)
+ table = Arel::Table.new(column, :engine => engine)
+ build_from_hash(engine, value, table)
else
column = column.to_s
if column.include?('.')
table_name, column = column.split('.', 2)
- table = Arel::Table.new(table_name, :engine => @engine)
+ table = Arel::Table.new(table_name, :engine => engine)
end
attribute = table[column] || Arel::Attribute.new(table, column)
@@ -38,6 +33,5 @@ module ActiveRecord
predicates.flatten
end
-
end
end