Sha256: 4613e68d4817a8626908914fa4b032d489196e0348d14e0d4f11ebf52ad02a1a
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
require 'pathname' require 'extlib/pathname' require 'rails_datamapper/session_store' module Rails module DataMapper class << self extend ActiveSupport::Memoizable def create_connection # TODO: handle Rails and Merb style database.yml files conf = config.dup repositories = conf.delete(:repositories) ::DataMapper.setup(:default, conf) unless conf.empty? end private def config_file File.new(File.expand_path('config/database.yml', Rails.root)) end def full_config YAML::load(ERB.new(config_file.read).result) end memoize :full_config def config if hash = full_config[Rails.env] || full_config[Rails.env.to_sym] normalize_config(hash) else raise ArgumentError, "missing environment '#{Rails.env}' in config file #{config_file}" end end memoize :config def normalize_config(hash) config = {} hash.symbolize_keys.each do |key, value| config[key] = if value.kind_of?(Hash) normalize_config(value) elsif key == :port value.to_i elsif key == :adapter && value == 'postgresql' 'postgres' else value end end config end end end end Rails::DataMapper.create_connection
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tpitale-rails_datamapper-0.10.3.1 | lib/rails_datamapper.rb |
tpitale-rails_datamapper-0.10.3 | lib/rails_datamapper.rb |