diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-19 21:50:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-20 09:15:09 -0700 |
commit | e1df4b956882f0c10a310088c1c13dcaa655a3b1 (patch) | |
tree | f654652dc11c0840ed57ee24ee236a5174070a89 | |
parent | 9df9c4bac008ba94c37faff411368c33408faff8 (diff) | |
download | rails-e1df4b956882f0c10a310088c1c13dcaa655a3b1.tar.gz rails-e1df4b956882f0c10a310088c1c13dcaa655a3b1.tar.bz2 rails-e1df4b956882f0c10a310088c1c13dcaa655a3b1.zip |
adding a reader for loaded, initializing @loaded to false
-rw-r--r-- | activerecord/lib/active_record/named_scope.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 9 |
2 files changed, 4 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb index 6596c695e2..417ff4b5eb 100644 --- a/activerecord/lib/active_record/named_scope.rb +++ b/activerecord/lib/active_record/named_scope.rb @@ -26,7 +26,7 @@ module ActiveRecord # You can define a \scope that applies to all finders using # ActiveRecord::Base.default_scope. def scoped(options = nil) - if options.present? + if options scoped.apply_finder_options(options) else current_scoped_methods ? relation.merge(current_scoped_methods) : relation.clone diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 7499100f55..86a210d2be 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -13,14 +13,15 @@ module ActiveRecord delegate :to_xml, :to_yaml, :length, :collect, :map, :each, :all?, :include?, :to => :to_a delegate :insert, :to => :arel - attr_reader :table, :klass + attr_reader :table, :klass, :loaded attr_accessor :extensions + alias :loaded? :loaded def initialize(klass, table) @klass, @table = klass, table @implicit_readonly = nil - @loaded = nil + @loaded = false SINGLE_VALUE_METHODS.each {|v| instance_variable_set(:"@#{v}_value", nil)} (ASSOCIATION_METHODS + MULTI_VALUE_METHODS).each {|v| instance_variable_set(:"@#{v}_values", [])} @@ -292,10 +293,6 @@ module ActiveRecord where(@klass.primary_key => id_or_array).delete_all end - def loaded? - @loaded - end - def reload reset to_a # force reload |