Sha256: fa487e14282942170a8dffb376095a5d9d5181729558cd6e4cd4a3e531f4d789

Contents?: true

Size: 403 Bytes

Versions: 1

Compression:

Stored size: 403 Bytes

Contents

Dir["#{File.dirname(__FILE__)}/caching/*.rb"].each { |file| require file }

module Caching

  def self.extended(klass)
    constructor = klass.method :new

    klass.define_singleton_method :new do |*args, &block|
      Proxy.new constructor.call(*args, &block), *@cached_methods
    end
  end

  def cache(*methods)
    @cached_methods = (@cached_methods ||= []) | methods.map(&:to_sym).uniq
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caching-0.0.1 lib/caching.rb