Sha256: 8f493cce8ef56d8e0ea508c025578ecdff9e4a8c427c950a40addb8016d9a34d

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 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], 
      )[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

1 entries across 1 versions & 1 rubygems

Version Path
couch_potato-1.12.0 lib/couch_potato/railtie.rb