Sha256: 71d7cb5a142b07141a6c8167cb64c0a74d0f86ad9cdf9446fe7a2313bbfa7281
Contents?: true
Size: 685 Bytes
Versions: 2
Compression:
Stored size: 685 Bytes
Contents
module Cacheable module MethodCache def with_method(*methods) self.cached_methods ||= [] self.cached_methods += methods class_eval do after_commit :expire_method_cache, :on => :update end methods.each do |meth| method_name = "cached_#{meth}" define_method(method_name) do iv = Cacheable.escape_punctuation("@#{method_name}") if instance_variable_get(iv).nil? instance_variable_set(iv, (Cacheable.fetch method_cache_key(meth) do send(meth) end) ) end instance_variable_get(iv) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_cacheable-1.5.1 | lib/cacheable/types/method_cache.rb |
simple_cacheable-1.5.0 | lib/cacheable/types/method_cache.rb |