Class: Stealth::Migrations::Configurator
- Inherits:
-
Object
- Object
- Stealth::Migrations::Configurator
- Defined in:
- lib/stealth/migrations/configurator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
- #config_for(environment) ⇒ Object
- #config_for_all ⇒ Object
-
#initialize(options = {}) ⇒ Configurator
constructor
A new instance of Configurator.
- #migrate_dir ⇒ Object
- #schema ⇒ Object
- #seeds ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configurator
Returns a new instance of Configurator.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/stealth/migrations/configurator.rb', line 35 def initialize( = {}) default_schema = ENV['SCHEMA'] || ActiveRecord::Tasks::DatabaseTasks.schema_file(ActiveRecord::Base.schema_format) defaults = { config: "config/database.yml", migrate_dir: "db/migrate", seeds: "db/seeds.rb", schema: default_schema } @options = defaults.merge() Rails.application.config.root = Pathname.pwd Rails.application.config.paths["config/database"] = config end |
Class Method Details
.environments_config {|proxy| ... } ⇒ Object
30 31 32 33 |
# File 'lib/stealth/migrations/configurator.rb', line 30 def self.environments_config proxy = InternalConfigurationsProxy.new(load_configurations) yield(proxy) if block_given? end |
.load_configurations ⇒ Object
23 24 25 26 27 28 |
# File 'lib/stealth/migrations/configurator.rb', line 23 def self.load_configurations self.new @env_config ||= Rails.application.config.database_configuration ActiveRecord::Base.configurations = @env_config @env_config end |
Instance Method Details
#config ⇒ Object
49 50 51 |
# File 'lib/stealth/migrations/configurator.rb', line 49 def config @options[:config] end |
#config_for(environment) ⇒ Object
69 70 71 |
# File 'lib/stealth/migrations/configurator.rb', line 69 def config_for(environment) config_for_all[environment.to_s] end |
#config_for_all ⇒ Object
65 66 67 |
# File 'lib/stealth/migrations/configurator.rb', line 65 def config_for_all Configurator.load_configurations.dup end |
#migrate_dir ⇒ Object
53 54 55 |
# File 'lib/stealth/migrations/configurator.rb', line 53 def migrate_dir @options[:migrate_dir] end |
#schema ⇒ Object
61 62 63 |
# File 'lib/stealth/migrations/configurator.rb', line 61 def schema @options[:schema] end |
#seeds ⇒ Object
57 58 59 |
# File 'lib/stealth/migrations/configurator.rb', line 57 def seeds @options[:seeds] end |