Sha256: d0407839a1eee35839b4cfb388f8143d6a93f22cc804182d0b38402a6680490f
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'active_support' require 'dotenv' module Gris class << self def load_environment env_file = Gris.env.test? ? '.env.test' : '.env' Dotenv.overload env_file end def env @_env ||= ActiveSupport::StringInquirer.new(ENV['RACK_ENV'] || 'development') end def env=(environment) @_env = ActiveSupport::StringInquirer.new(environment) end def db_connection_details YAML.load(ERB.new(File.read('./config/database.yml')).result)[Gris.env] end def cache @_cache ||= ActiveSupport::Cache.lookup_store(:memory_store) end def cache=(store_option) @_cache = ActiveSupport::Cache.lookup_store(store_option) end end end # prevent DalliError: Unable to unmarshal value: undefined class/module Gris.cache.instance_eval do def fetch(key, options = {}, rescue_and_require = true) super(key, options) rescue ArgumentError => ex if rescue_and_require && %r{^undefined class\/module (.+?)$} =~ ex.message self.class.const_missing(Regexp.last_match(1)) fetch(key, options, false) else raise ex end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gris-0.2.4 | lib/gris/setup.rb |
gris-0.2.3 | lib/gris/setup.rb |
gris-0.2.2 | lib/gris/setup.rb |