diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:41:27 -0700 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-03-16 15:41:27 -0700 |
commit | ed9c8d4d828fe4e28c1e37ed8921acbee54450f2 (patch) | |
tree | f650c5b558a21683e55169fbb1defe614733f725 /lib | |
parent | 1a6a3a1c6aa2f75333edef9100951407c4f76f1f (diff) | |
download | rails-ed9c8d4d828fe4e28c1e37ed8921acbee54450f2.tar.gz rails-ed9c8d4d828fe4e28c1e37ed8921acbee54450f2.tar.bz2 rails-ed9c8d4d828fe4e28c1e37ed8921acbee54450f2.zip |
renamed strategy to formatter
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_relation/extensions/array.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/extensions/hash.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/extensions/object.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/predicates.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/primitives/attribute.rb | 8 | ||||
-rw-r--r-- | lib/active_relation/primitives/expression.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/primitives/value.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/relations/deletion.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/relations/insertion.rb | 2 | ||||
-rw-r--r-- | lib/active_relation/relations/relation.rb | 4 | ||||
-rw-r--r-- | lib/active_relation/relations/update.rb | 2 |
11 files changed, 18 insertions, 18 deletions
diff --git a/lib/active_relation/extensions/array.rb b/lib/active_relation/extensions/array.rb index 3b4246fb1c..5e2981a4c5 100644 --- a/lib/active_relation/extensions/array.rb +++ b/lib/active_relation/extensions/array.rb @@ -3,7 +3,7 @@ class Array Hash[*flatten] end - def to_sql(strategy = Sql::SelectExpression.new) - strategy.array self + def to_sql(formatter = Sql::SelectExpression.new) + formatter.array self end end
\ No newline at end of file diff --git a/lib/active_relation/extensions/hash.rb b/lib/active_relation/extensions/hash.rb index ae3e48146f..133eab1026 100644 --- a/lib/active_relation/extensions/hash.rb +++ b/lib/active_relation/extensions/hash.rb @@ -9,7 +9,7 @@ class Hash end end - def to_sql(strategy = nil) + def to_sql(formatter = nil) '(' + inject([]) do |values, (key, value)| values << key.format(value) diff --git a/lib/active_relation/extensions/object.rb b/lib/active_relation/extensions/object.rb index 2682ed99fe..cd51543c91 100644 --- a/lib/active_relation/extensions/object.rb +++ b/lib/active_relation/extensions/object.rb @@ -3,8 +3,8 @@ class Object ActiveRelation::Value.new(self, relation) end - def to_sql(strategy = nil) - strategy.scalar self + def to_sql(formatter = nil) + formatter.scalar self end def metaclass diff --git a/lib/active_relation/predicates.rb b/lib/active_relation/predicates.rb index 12ddd1b48d..98a966507f 100644 --- a/lib/active_relation/predicates.rb +++ b/lib/active_relation/predicates.rb @@ -24,7 +24,7 @@ module ActiveRelation descend(&:qualify) end - def to_sql(strategy = nil) + def to_sql(formatter = nil) "#{operand2.format(operand1)} #{predicate_sql} #{operand1.format(operand2)}" end diff --git a/lib/active_relation/primitives/attribute.rb b/lib/active_relation/primitives/attribute.rb index f2c484cc59..fc857347fc 100644 --- a/lib/active_relation/primitives/attribute.rb +++ b/lib/active_relation/primitives/attribute.rb @@ -111,16 +111,16 @@ module ActiveRelation end include Expressions - def to_sql(strategy = Sql::WhereCondition.new(engine)) - strategy.attribute prefix, name, self.alias + def to_sql(formatter = Sql::WhereCondition.new(engine)) + formatter.attribute prefix, name, self.alias end def format(object) - object.to_sql(strategy) + object.to_sql(formatter) end private - def strategy + def formatter Sql::Attribute.new(self) end diff --git a/lib/active_relation/primitives/expression.rb b/lib/active_relation/primitives/expression.rb index 11aa558977..2df2888ba0 100644 --- a/lib/active_relation/primitives/expression.rb +++ b/lib/active_relation/primitives/expression.rb @@ -25,7 +25,7 @@ module ActiveRelation end include Transformations - def to_sql(strategy = nil) + def to_sql(formatter = nil) "#{function_sql}(#{attribute.to_sql})" + (@alias ? " AS #{quote_column_name(@alias)}" : '') end diff --git a/lib/active_relation/primitives/value.rb b/lib/active_relation/primitives/value.rb index 096c876ecd..131610f2e9 100644 --- a/lib/active_relation/primitives/value.rb +++ b/lib/active_relation/primitives/value.rb @@ -6,8 +6,8 @@ module ActiveRelation @value, @relation = value, relation end - def to_sql(strategy = Sql::WhereCondition.new(relation.engine)) - strategy.value value + def to_sql(formatter = Sql::WhereCondition.new(relation.engine)) + formatter.value value end def format(object) diff --git a/lib/active_relation/relations/deletion.rb b/lib/active_relation/relations/deletion.rb index 0fcf523efe..1b94df8729 100644 --- a/lib/active_relation/relations/deletion.rb +++ b/lib/active_relation/relations/deletion.rb @@ -4,7 +4,7 @@ module ActiveRelation @relation = relation end - def to_sql(strategy = nil) + def to_sql(formatter = nil) [ "DELETE", "FROM #{table_sql}", diff --git a/lib/active_relation/relations/insertion.rb b/lib/active_relation/relations/insertion.rb index 7a13bc06bb..bcf8e33e0a 100644 --- a/lib/active_relation/relations/insertion.rb +++ b/lib/active_relation/relations/insertion.rb @@ -6,7 +6,7 @@ module ActiveRelation @relation, @record = relation, record end - def to_sql(strategy = nil) + def to_sql(formatter = nil) [ "INSERT", "INTO #{table_sql}", diff --git a/lib/active_relation/relations/relation.rb b/lib/active_relation/relations/relation.rb index 039af61925..8c93f948f7 100644 --- a/lib/active_relation/relations/relation.rb +++ b/lib/active_relation/relations/relation.rb @@ -102,8 +102,8 @@ module ActiveRelation false end - def to_sql(strategy = Sql::SelectStatement.new(engine)) - strategy.select [ + def to_sql(formatter = Sql::SelectStatement.new(engine)) + formatter.select [ "SELECT #{attributes.collect { |a| a.to_sql(Sql::SelectExpression.new(engine)) }.join(', ')}", "FROM #{table_sql}", (joins unless joins.blank? ), diff --git a/lib/active_relation/relations/update.rb b/lib/active_relation/relations/update.rb index a51f248866..dc88ea0362 100644 --- a/lib/active_relation/relations/update.rb +++ b/lib/active_relation/relations/update.rb @@ -6,7 +6,7 @@ module ActiveRelation @relation, @assignments = relation, assignments end - def to_sql(strategy = nil) + def to_sql(formatter = nil) [ "UPDATE #{table_sql} SET", assignments.inject("") do |assignments, (attribute, value)| |