1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fixing variable names to reflect reality

This commit is contained in:
Aaron Patterson 2011-02-15 15:35:10 -08:00
parent 13e72db770
commit 8c4c07e4cb

View file

@ -872,29 +872,29 @@ module ActiveRecord
end end
end end
def setup_fixture_accessors(table_names = nil) def setup_fixture_accessors(fixture_names = nil)
table_names = Array.wrap(table_names || fixture_table_names) fixture_names = Array.wrap(fixture_names || fixture_table_names)
table_names.each do |table_name| fixture_names.each do |fixture_name|
table_name = table_name.to_s.tr('./', '_') fixture_name = fixture_name.to_s.tr('./', '_')
redefine_method(table_name) do |*fixtures| redefine_method(fixture_name) do |*fixtures|
force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload force_reload = fixtures.pop if fixtures.last == true || fixtures.last == :reload
@fixture_cache[table_name] ||= {} @fixture_cache[fixture_name] ||= {}
instances = fixtures.map do |fixture| instances = fixtures.map do |fixture|
@fixture_cache[table_name].delete(fixture) if force_reload @fixture_cache[fixture_name].delete(fixture) if force_reload
if @loaded_fixtures[table_name][fixture.to_s] if @loaded_fixtures[fixture_name][fixture.to_s]
@fixture_cache[table_name][fixture] ||= @loaded_fixtures[table_name][fixture.to_s].find @fixture_cache[fixture_name][fixture] ||= @loaded_fixtures[fixture_name][fixture.to_s].find
else else
raise StandardError, "No fixture with name '#{fixture}' found for table '#{table_name}'" raise StandardError, "No fixture with name '#{fixture}' found for table '#{fixture_name}'"
end end
end end
instances.size == 1 ? instances.first : instances instances.size == 1 ? instances.first : instances
end end
private table_name private fixture_name
end end
end end