aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2012-05-09 19:01:34 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2012-05-09 19:01:34 -0700
commit22a60728a9495ac75075d1d27a706ae7f2df2529 (patch)
tree184494fabe2d34960e1bcfffbc3e994d4988aa51 /activerecord
parentf8dae865b5f33bd1846e93aa19dcdb52a5665461 (diff)
parent981055540c8a1fc66669cfef29b437083e2fb7d6 (diff)
downloadrails-22a60728a9495ac75075d1d27a706ae7f2df2529.tar.gz
rails-22a60728a9495ac75075d1d27a706ae7f2df2529.tar.bz2
rails-22a60728a9495ac75075d1d27a706ae7f2df2529.zip
Merge pull request #6221 from alexeymuranov/deprecate__instantiate_fixtures__arity
Deprecate ActiveRecord::Fixtures.instantiate_fixtures unused parameter
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/fixtures.rb33
1 files changed, 26 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index d8340bf1c9..296639f35a 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -419,11 +419,15 @@ module ActiveRecord
cache_for_connection(connection).update(fixtures_map)
end
- def self.instantiate_fixtures(object, fixture_name, fixtures, load_instances = true)
+ #--
+ # TODO:NOTE: in the next version, the __with_new_arity suffix and
+ # the method with the old arity will be removed.
+ #++
+ def self.instantiate_fixtures__with_new_arity(object, fixture_set, load_instances = true) # :nodoc:
if load_instances
- fixtures.each do |name, fixture|
+ fixture_set.each do |fixture_name, fixture|
begin
- object.instance_variable_set "@#{name}", fixture.find
+ object.instance_variable_set "@#{fixture_name}", fixture.find
rescue FixtureClassNotFound
nil
end
@@ -431,9 +435,24 @@ module ActiveRecord
end
end
+ # The use with parameters <tt>(object, fixture_set_name, fixture_set, load_instances = true)</tt> is deprecated, +fixture_set_name+ parameter is not used.
+ # Use as:
+ #
+ # instantiate_fixtures(object, fixture_set, load_instances = true)
+ def self.instantiate_fixtures(object, fixture_set, load_instances = true, rails_3_2_compatibility_argument = true)
+ unless load_instances == true || load_instances == false
+ ActiveSupport::Deprecation.warn(
+ "ActiveRecord::Fixtures.instantiate_fixtures with parameters (object, fixture_set_name, fixture_set, load_instances = true) is deprecated and shall be removed from future releases. Use it with parameters (object, fixture_set, load_instances = true) instead (skip fixture_set_name).",
+ caller)
+ fixture_set = load_instances
+ load_instances = rails_3_2_compatibility_argument
+ end
+ instantiate_fixtures__with_new_arity(object, fixture_set, load_instances)
+ end
+
def self.instantiate_all_loaded_fixtures(object, load_instances = true)
- all_loaded_fixtures.each do |table_name, fixtures|
- ActiveRecord::Fixtures.instantiate_fixtures(object, table_name, fixtures, load_instances)
+ all_loaded_fixtures.each_value do |fixture_set|
+ ActiveRecord::Fixtures.instantiate_fixtures(object, fixture_set, load_instances)
end
end
@@ -893,8 +912,8 @@ module ActiveRecord
ActiveRecord::Fixtures.instantiate_all_loaded_fixtures(self, load_instances?)
else
raise RuntimeError, 'Load fixtures before instantiating them.' if @loaded_fixtures.nil?
- @loaded_fixtures.each do |fixture_name, fixtures|
- ActiveRecord::Fixtures.instantiate_fixtures(self, fixture_name, fixtures, load_instances?)
+ @loaded_fixtures.each_value do |fixture_set|
+ ActiveRecord::Fixtures.instantiate_fixtures(self, fixture_set, load_instances?)
end
end
end