Class: StandaloneMigrations::Configurator
- Inherits:
-
Object
- Object
- StandaloneMigrations::Configurator
- Defined in:
- lib/standalone_migrations/configurator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #c_o_p_m ⇒ Object
- #c_os ⇒ Object
- #config_for(environment) ⇒ Object
- #config_for_all ⇒ Object
- #config_override_path_mappings ⇒ Object
- #config_overrides ⇒ Object
- #defaults ⇒ Object
-
#initialize(options = {}) ⇒ Configurator
constructor
A new instance of Configurator.
- #schema ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configurator
Returns a new instance of Configurator.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/standalone_migrations/configurator.rb', line 33 def initialize( = {}) = .dup @schema = .delete('schema') @config_overrides = defaults c_os['paths'].merge!(.delete('paths') || {}) c_os.merge!() load_from_file ENV['SCHEMA'] ||= @schema if @schema rac = Rails.application.config rac.root = c_os['root'] c_os['paths'].each do |path, value| rac.paths[path] = value end end |
Class Method Details
.environments_config {|proxy| ... } ⇒ Object
28 29 30 31 |
# File 'lib/standalone_migrations/configurator.rb', line 28 def self.environments_config proxy = InternalConfigurationsProxy.new(load_configurations) yield(proxy) if block_given? end |
.load_configurations ⇒ Object
22 23 24 25 26 |
# File 'lib/standalone_migrations/configurator.rb', line 22 def self.load_configurations @env_config ||= Rails.application.config.database_configuration ActiveRecord::Base.configurations = @env_config @env_config end |
Instance Method Details
#c_o_p_m ⇒ Object
66 67 68 |
# File 'lib/standalone_migrations/configurator.rb', line 66 def c_o_p_m config_override_path_mappings end |
#c_os ⇒ Object
59 60 61 |
# File 'lib/standalone_migrations/configurator.rb', line 59 def c_os config_overrides end |
#config_for(environment) ⇒ Object
55 56 57 |
# File 'lib/standalone_migrations/configurator.rb', line 55 def config_for(environment) config_for_all[environment.to_s] end |
#config_for_all ⇒ Object
51 52 53 |
# File 'lib/standalone_migrations/configurator.rb', line 51 def config_for_all Configurator.load_configurations.dup end |
#config_override_path_mappings ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/standalone_migrations/configurator.rb', line 69 def config_override_path_mappings { 'config/database' => { 'config_key_path' => ['config', 'database'], 'default' => 'db/config.yml' }, 'db' => { 'config_key_path' => ['db' , 'dir' ], 'default' => 'db' }, 'db/migrate' => { 'config_key_path' => ['db' , 'migrate' ], 'default' => 'db/migrate' }, 'db/seeds.rb' => { 'config_key_path' => ['db' , 'seeds' ], 'default' => 'db/seeds.rb' }, } end |
#config_overrides ⇒ Object
62 63 64 |
# File 'lib/standalone_migrations/configurator.rb', line 62 def config_overrides @config_overrides end |
#defaults ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'lib/standalone_migrations/configurator.rb', line 90 def defaults { 'paths' => c_o_p_m.map do |path, value| [ path, value['default'] ] end.to_h, 'root' => Pathname.pwd, } end |
#schema ⇒ Object
99 100 101 |
# File 'lib/standalone_migrations/configurator.rb', line 99 def schema @schema end |