Class: Shitcan::Config
- Inherits:
-
Object
- Object
- Shitcan::Config
- Defined in:
- lib/shitcan/config.rb
Instance Attribute Summary collapse
-
#app_root ⇒ Object
Returns the value of attribute app_root.
-
#env ⇒ Object
Returns the value of attribute env.
Instance Method Summary collapse
- #cache ⇒ Object
-
#initialize(opts = {}) ⇒ Config
constructor
A new instance of Config.
- #memcache_conf ⇒ Object
-
#shitcan_conf ⇒ Object
TODO: Think up some custom configuration options.
Constructor Details
#initialize(opts = {}) ⇒ Config
Returns a new instance of Config.
5 6 7 8 |
# File 'lib/shitcan/config.rb', line 5 def initialize(opts={}) @app_root = opts[:app_root] || RAILS_ROOT @env = opts[:rails_env] || RAILS_ENV || 'development' end |
Instance Attribute Details
#app_root ⇒ Object
Returns the value of attribute app_root.
3 4 5 |
# File 'lib/shitcan/config.rb', line 3 def app_root @app_root end |
#env ⇒ Object
Returns the value of attribute env.
3 4 5 |
# File 'lib/shitcan/config.rb', line 3 def env @env end |
Instance Method Details
#cache ⇒ Object
21 22 23 |
# File 'lib/shitcan/config.rb', line 21 def cache @cache ||= Memcached.new(memcache_conf) end |
#memcache_conf ⇒ Object
10 11 12 13 |
# File 'lib/shitcan/config.rb', line 10 def memcache_conf path = "#{app_root}/config/memcache.yml" @memcache_conf ||= File.exists?(path) ? YAML::load(ERB.new(IO.read(path)).result)[env] : 'localhost:11211' end |
#shitcan_conf ⇒ Object
TODO: Think up some custom configuration options
16 17 18 19 |
# File 'lib/shitcan/config.rb', line 16 def shitcan_conf path = "#{app_root}/config/shitcan.yml" @shitcan_conf ||= YAML::load(ERB.new(IO.read(path)).result)[env] end |