Class: Kibutsu::FixtureWorld

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/kibutsu/fixture_world.rb

Overview

Singleton class that holds all the information about fixtures and fixture tables. This class really ties whole the gem together.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fixture_tablesObject (readonly)

Returns the value of attribute fixture_tables.



40
41
42
# File 'lib/kibutsu/fixture_world.rb', line 40

def fixture_tables
  @fixture_tables
end

Instance Method Details

#find_table(table_name) ⇒ Object



36
37
38
# File 'lib/kibutsu/fixture_world.rb', line 36

def find_table(table_name)
  @fixture_tables.find { |table| table.name == table_name }
end

#load(database_connection_url, fixtures_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/kibutsu/fixture_world.rb', line 13

def load(database_connection_url, fixtures_path)
  @database_connection = Kibutsu::DatabaseConnection.new(
    database_connection_url
  )

  load_fixtures(fixtures_path)
  database_connection.insert_fixture_tables(tables_without_dependencies)
ensure
  database_connection.disconnect
end

#load_fixtures(fixtures_path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kibutsu/fixture_world.rb', line 24

def load_fixtures(fixtures_path)
  initialize_empty_fixture_tables
  fill_fixture_table_information

  fixture_file_paths = FixtureFinder.new(fixtures_path).fixture_file_paths
  fixture_file_paths.each do |fixture_file_path|
    FixtureLoader.new(
      fixture_file_path, database_connection
    ).load_fixture_tables
  end
end