aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/Rakefile
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2018-03-16 13:20:04 -0400
committereileencodes <eileencodes@gmail.com>2018-03-21 13:53:24 -0400
commit1756094b22bf81f15ffdfdb5208075b58c45296f (patch)
treec9345a24b464e1aefc9d7343edf1df8fe6ae69c4 /activerecord/Rakefile
parent627ef06331b5c6c30e6100bfdaa38dbeb18c037a (diff)
downloadrails-1756094b22bf81f15ffdfdb5208075b58c45296f.tar.gz
rails-1756094b22bf81f15ffdfdb5208075b58c45296f.tar.bz2
rails-1756094b22bf81f15ffdfdb5208075b58c45296f.zip
Add DatabaseConfig Struct and associated methods
Passing around and parsing hashes is easy if you know that it's a two tier config and each key will be named after the environment and each value will be the config for that environment key. This falls apart pretty quickly with three-tier configs. We have no idea what the second tier will be named (we know the first is primary but we don't know the second), we have no easy way of figuring out how deep a hash we have without iterating over it, and we'd have to do this a lot throughout the code since it breaks all of Active Record's assumptions regarding configurations. These methods allow us to pass around objects instead. This will allow us to more easily parse the configs for the rake tasks. Evenually I'd like to replace the Active Record connection management that passes around config hashes to use these methods as well but that's much farther down the road. `walk_configs` takes an environment, specification name, and a config and turns them into DatabaseConfig struct objects so we can ask the configs questions like: ``` db_config.spec_name => animals db_config.env_name => development db_config.config { :adapter => mysql etc } ``` `db_configs` loops through all given configurations and returns an array of DatabaseConfig structs for each config in the yaml file. and lastly `configs_for` takes an environment and either returns the spec name and config if a block is given or returns an array of DatabaseConfig structs just for the given environment.
Diffstat (limited to 'activerecord/Rakefile')
0 files changed, 0 insertions, 0 deletions