Sha256: 87e19430f9dcab179da91d087b29ee332a324e815ca628eda0e24f1a369d19c2

Contents?: true

Size: 810 Bytes

Versions: 6

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

require 'erb'

module CouchPotato
  def self.rails_init
    require File.expand_path(File.dirname(__FILE__) + '/../../rails/reload_classes') if Rails.env.development?
    path = Rails.root.join('config/couchdb.yml')
    if File.exist?(path)
      require 'yaml'
      config = YAML.safe_load(
        ERB.new(File.read(path)).result, 
        permitted_classes: [Symbol], 
        aliases: true
      )[Rails.env]
      CouchPotato.configure(config)
    else
      Rails.logger.warn 'Rails.root/config/couchdb.yml does not exist. Not configuring a database.'
    end
  end

  if defined?(::Rails::Railtie)
    class Railtie < ::Rails::Railtie
      initializer 'couch_potato.load_config' do |_app|
        CouchPotato.rails_init
      end
    end
  else
    rails_init
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
couch_potato-1.17.0 lib/couch_potato/railtie.rb
couch_potato-1.16.0 lib/couch_potato/railtie.rb
couch_potato-1.15.0 lib/couch_potato/railtie.rb
couch_potato-1.14.0 lib/couch_potato/railtie.rb
couch_potato-1.13.0 lib/couch_potato/railtie.rb
couch_potato-1.12.1 lib/couch_potato/railtie.rb