Module: Cardio::Seed
- Defined in:
- lib/cardio/seed.rb
Overview
methods in support of seeding
Constant Summary collapse
- TABLES =
%w[cards card_actions card_acts card_changes card_references schema_migrations schema_migrations_core_cards schema_migrations_deck schema_migrations_deck_cards].freeze
Class Method Summary collapse
Class Method Details
.clean ⇒ Object
43 44 45 46 47 |
# File 'lib/cardio/seed.rb', line 43 def clean Card::Act.update_all actor_id: clean_history clean_time_and_user_stamps end |
.default_path ⇒ Object
9 10 11 |
# File 'lib/cardio/seed.rb', line 9 def default_path db_path Cardio.config.seed_type, 0 end |
.dump ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cardio/seed.rb', line 32 def dump dump_tables.each do |table| i = "000" # TODO: use card keys instead (this is just a label) write_seed_file table do yamlize_records table do |record, hash| hash["#{table}_#{i.succ!}"] = record end end end end |
.load ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/cardio/seed.rb', line 21 def load ActiveRecord::FixtureSet.create_fixtures path, load_tables return unless update_seed? Cardio::Migration.assume_current Cardio::Migration::Core.assume_current Cardio::Migration::DeckStructure.assume_current # Cardio::Migration::Core.assume_current end |
.path ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cardio/seed.rb', line 13 def path if update_seed? db_path :real, (Rails.env.test? ? 0 : 1) else default_path end end |