diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-11 16:22:38 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-02-11 16:22:38 -0800 |
commit | e0802fa1766ab70d04a2d52f2c79f0ca818d6674 (patch) | |
tree | a7493304e11439098af4fbba302e3c7564acd326 /activerecord | |
parent | af5b1db965d986f563d19d5dd23df9925b43d5fb (diff) | |
download | rails-e0802fa1766ab70d04a2d52f2c79f0ca818d6674.tar.gz rails-e0802fa1766ab70d04a2d52f2c79f0ca818d6674.tar.bz2 rails-e0802fa1766ab70d04a2d52f2c79f0ca818d6674.zip |
avoid side effects from method calls, localize ivar assignment
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index fba05b16d7..962698b2fd 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -955,7 +955,8 @@ module ActiveRecord if @@already_loaded_fixtures[self.class] @loaded_fixtures = @@already_loaded_fixtures[self.class] else - @@already_loaded_fixtures[self.class] = load_fixtures + @loaded_fixtures = load_fixtures + @@already_loaded_fixtures[self.class] = @loaded_fixtures end ActiveRecord::Base.connection.increment_open_transactions ActiveRecord::Base.connection.transaction_joinable = false @@ -964,7 +965,7 @@ module ActiveRecord else Fixtures.reset_cache @@already_loaded_fixtures[self.class] = nil - load_fixtures + @loaded_fixtures = load_fixtures end # Instantiate fixtures for every test if requested. @@ -989,7 +990,7 @@ module ActiveRecord private def load_fixtures fixtures = Fixtures.create_fixtures(fixture_path, fixture_table_names, fixture_class_names) - @loaded_fixtures = Hash[fixtures.map { |f| [f.name, f] }] + Hash[fixtures.map { |f| [f.name, f] }] end # for pre_loaded_fixtures, only require the classes once. huge speed improvement |