Class: Rails::ActivePStore::Railtie
- Inherits:
-
Railtie
- Object
- Railtie
- Rails::ActivePStore::Railtie
- Defined in:
- lib/active_pstore/railtie.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#database_configuration ⇒ Object
Loads and returns the entire raw configuration of database from values stored in ‘config/active_pstore.yml`.
Class Method Details
.rescue_responses ⇒ Object
4 5 6 7 8 |
# File 'lib/active_pstore/railtie.rb', line 4 def self.rescue_responses { 'ActivePStore::RecordNotFound' => :not_found } end |
Instance Method Details
#database_configuration ⇒ Object
Loads and returns the entire raw configuration of database from values stored in ‘config/active_pstore.yml`.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/active_pstore/railtie.rb', line 16 def database_configuration yaml = Pathname.new('config/active_pstore.yml') config = if yaml && yaml.exist? require 'yaml' require 'erb' YAML.load(ERB.new(yaml.read).result) || {} else raise 'Could not load database configuration. No such file - config/active_pstore.yml' end config rescue Psych::SyntaxError => e raise "YAML syntax error occurred while parsing config/active_pstore.yml. " \ "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \ "Error: #{e.}" rescue => e raise e, "Cannot load `Rails::ActivePStore::Railtie.database_configuration`:\n#{e.}", e.backtrace end |