Sha256: 6f70e62587dfb9d64f77d0c0f6af987117cfce297a6d0f03bf12359fe6446f4f
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
# encoding: utf-8 require 'xapian_db' require 'rails' module XapianDb # Configuration for a rails app # @author Gernot Kogler class Railtie < ::Rails::Railtie config.before_configuration do # Read the database configuration file if there is one config_file_path = "#{Rails.root}/config/xapian_db.yml" if File.exist?(config_file_path) db_config = YAML::load_file config_file_path env_config = db_config[Rails.env] database_path = env_config["database"] || ":memory:" adapter = env_config["adapter"] || :active_record writer = env_config["writer"] || :direct else # No config file, set the defaults Rails.env == "test" ? database_path = ":memory:" : database_path = "db/xapian_db/#{Rails.env}" adapter = :active_record writer = :direct end # Do the configuration XapianDb::Config.setup do |config| if database_path == ":memory:" config.database :memory else config.database database_path end config.adapter adapter.to_sym config.writer writer.to_sym config.language(env_config["language"]) if env_config["language"] end end config.to_prepare do # Load a blueprint config if there is one blueprints_file_path = "#{Rails.root}/config/xapian_blueprints.rb" load blueprints_file_path if File.exist?(blueprints_file_path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
xapian_db-0.4.1 | lib/xapian_db/railtie.rb |
xapian_db-0.4.0 | lib/xapian_db/railtie.rb |