Class: Kibutsu::FixtureLoader
- Inherits:
-
Object
- Object
- Kibutsu::FixtureLoader
- Defined in:
- lib/kibutsu/fixture_loader.rb
Overview
Loads fixtures from files, optionally with ERB pre-processing and creates Fixture objects from them.
Instance Method Summary collapse
-
#initialize(fixture_file_path, database_connection) ⇒ FixtureLoader
constructor
A new instance of FixtureLoader.
- #load_fixture_tables ⇒ Object
Constructor Details
#initialize(fixture_file_path, database_connection) ⇒ FixtureLoader
Returns a new instance of FixtureLoader.
11 12 13 14 |
# File 'lib/kibutsu/fixture_loader.rb', line 11 def initialize(fixture_file_path, database_connection) @fixture_file_path = fixture_file_path @database_connection = database_connection end |
Instance Method Details
#load_fixture_tables ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kibutsu/fixture_loader.rb', line 16 def load_fixture_tables file_content = File.read(fixture_file_path) yaml_content = if fixture_file_path.end_with? '.yml.erb' run_erb(file_content) else file_content end fixtures_hash = load_fixture(yaml_content) build_fixture_tables(fixtures_hash) end |