huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

Strict dependency on 'Rails' #58

Closed arnaldodg closed 5 years ago

arnaldodg commented 9 years ago

Sometimes it would be useful to have it working on a non-rails project. The Rails gem dependency makes it not possible. I noticed there are calls for the Rails.cache objects. Isn't there a way of creating specific depencencies for the Rails.cache classes? eg: require 'rails/cache'. In this fashion one could add other require statments like 'activesupport/all' and 'activerecord' to make it work on a plain ruby+pg setup.

Nice work, by the way. Thanks for this valuable gem.

huacnlee commented 9 years ago

You can create a fake Rails.cache by implement with ActiveSupport::Cache::Store like this:

module Rails
  class << self
    def cache
      @cache ||= ActiveSupport::Cache::MemCacheStore.new('127.0.0.1')
    end
  end
end