[#350] Refactor: extract method

This commit is contained in:
Eric Davis 2011-05-27 14:52:44 -07:00
parent c51a32ac23
commit e4fac8d40f
1 changed files with 8 additions and 3 deletions

View File

@ -148,11 +148,16 @@ class Setting < ActiveRecord::Base
cache_cleared_on = Rails.cache.read('chiliproject/setting-cleared_on')
cache_cleared_on = cache_cleared_on ? Marshal.load(cache_cleared_on) : Time.now
if settings_updated_on && cache_cleared_on <= settings_updated_on
Rails.cache.delete_matched( /^chiliproject\/setting\/.+$/ )
Rails.cache.write('chiliproject/setting-cleared_on', Marshal.dump(Time.now))
logger.info 'Settings cache cleared.' if logger
clear_cache
end
end
# Clears all of the Setting caches
def self.clear_cache
Rails.cache.delete_matched( /^chiliproject\/setting\/.+$/ )
Rails.cache.write('chiliproject/setting-cleared_on', Marshal.dump(Time.now))
logger.info 'Settings cache cleared.' if logger
end
private
# Returns the Setting instance for the setting named name