diff options
author | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-24 22:19:32 -0800 |
---|---|---|
committer | Nick Kallen <nkallen@nick-kallens-computer-2.local> | 2008-02-24 22:19:32 -0800 |
commit | 92db013ba3ee4d0a9d92281e614d05f064c22e15 (patch) | |
tree | 23585e771ee1a2b1682f66a67d6b6891fab49f24 /lib/active_relation/extensions | |
parent | ecd072d21951573f59e9515b868224d3732dbdfa (diff) | |
download | rails-92db013ba3ee4d0a9d92281e614d05f064c22e15.tar.gz rails-92db013ba3ee4d0a9d92281e614d05f064c22e15.tar.bz2 rails-92db013ba3ee4d0a9d92281e614d05f064c22e15.zip |
quoting issues
Diffstat (limited to 'lib/active_relation/extensions')
-rw-r--r-- | lib/active_relation/extensions/base.rb | 48 | ||||
-rw-r--r-- | lib/active_relation/extensions/object.rb | 6 |
2 files changed, 5 insertions, 49 deletions
diff --git a/lib/active_relation/extensions/base.rb b/lib/active_relation/extensions/base.rb deleted file mode 100644 index c1b823f9a7..0000000000 --- a/lib/active_relation/extensions/base.rb +++ /dev/null @@ -1,48 +0,0 @@ -class ActiveRecord::Base - class << self - def cache - @identity_map ||= IdentityMap.new - end - - def relation - @relation ||= ActiveRelation::Table.new(table_name) - end - end - - class IdentityMap - def initialize - @map = {} - end - - def get(record, &block) - @map[record] ||= yield - end - end -end - -# all of the below disables normal AR behavior. It's rather destructive and purely for demonstration purposes (see scratch_spec). -class ActiveRecord::Associations::BelongsToAssociation - def instantiate(record, joins = []) - @target = proxy_reflection.klass.instantiate(record, joins) - loaded - end - - # this basically disables belongs_to from loading themselves - def reload - @target = 'hack' - end -end - -class ActiveRecord::Associations::AssociationCollection - def instantiate(record, joins = []) - @target << proxy_reflection.klass.instantiate(record, joins) - loaded # technically, this isn't true. doesn't matter though - end -end - -class ActiveRecord::Associations::HasManyThroughAssociation - def instantiate(record, joins = []) - @target << proxy_reflection.klass.instantiate(record, joins) - loaded # again, not really true. - end -end
\ No newline at end of file diff --git a/lib/active_relation/extensions/object.rb b/lib/active_relation/extensions/object.rb index 35ffa9c661..0cc87bf262 100644 --- a/lib/active_relation/extensions/object.rb +++ b/lib/active_relation/extensions/object.rb @@ -7,7 +7,11 @@ class Object self end - def to_sql(strategy = ActiveRelation::Sql::Scalar.new) + def to_sql(strategy = self.strategy) strategy.scalar self end + + def strategy + ActiveRelation::Sql::Scalar.new + end end
\ No newline at end of file |