module FoundersToolkit::Util::Cacheable

Public Instance Methods

cached(method_name) click to toggle source
# File lib/founders_toolkit/util/cacheable.rb, line 8
def cached(method_name)
  define_method("cached_#{method_name}") do |*args|
    Rails.cache.fetch([method_name, *args]) do
      __send__("unlocked_#{method_name}".to_sym, *args)
    end
  end

  alias_method "cached_#{method_name}".to_sym, method_name.to_sym
  alias_method method_name.to_sym, "cached_#{method_name}".to_sym
end