Module: Biovision::Migrations::ComponentMigration
- Defined in:
- app/lib/biovision/migrations/component_migration.rb
Overview
Mix-ins for repeated component migration parts
Instance Method Summary collapse
-
#component ⇒ Object
Component class.
-
#down ⇒ Object
Drops tables for each dependent model Removes BiovisionComponent.
-
#up ⇒ Object
Create component tables and roles.
Instance Method Details
#component ⇒ Object
Component class
8 9 10 |
# File 'app/lib/biovision/migrations/component_migration.rb', line 8 def component @component ||= find_component end |
#down ⇒ Object
Drops tables for each dependent model Removes BiovisionComponent
32 33 34 35 36 37 |
# File 'app/lib/biovision/migrations/component_migration.rb', line 32 def down component.dependent_models.reverse.each do |model| drop_table model.table_name if model.table_exists? end BiovisionComponent[component]&.destroy end |
#up ⇒ Object
Create component tables and roles
Creates new BiovisionComponent For each dependent model, calls “create_<table_name>” method Creates roles for new component
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/lib/biovision/migrations/component_migration.rb', line 17 def up component.create component.dependent_models.each do |model| next if model.table_exists? = "create_#{model.table_name}".to_sym send() if respond_to?(, true) end handler = component[nil] handler.create_roles handler.seed if handler.respond_to?(:seed) end |