Sha256: c99c1e49a5e3a9601786266037f3bd0c77166ab89e78e0b9fd738934708fcc1e

Contents?: true

Size: 382 Bytes

Versions: 32

Compression:

Stored size: 382 Bytes

Contents

#
#
module Helpers
  module Cache
    # This is a simple cache.
    # The store needs to be able to answer to [] and []=.
    #
    def cached store, key, &block
      # Get cached result
      #
      results = store[key]
      return results if results

      results = lambda(&block).call

      # Store results
      #
      store[key] = results

      results
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
picky-0.12.3 lib/picky/helpers/cache.rb
picky-0.12.2 lib/picky/helpers/cache.rb
picky-0.12.1 lib/picky/helpers/cache.rb
picky-0.12.0 lib/picky/helpers/cache.rb
picky-0.11.2 lib/picky/helpers/cache.rb
picky-0.11.1 lib/picky/helpers/cache.rb
picky-0.11.0 lib/picky/helpers/cache.rb
picky-0.10.5 lib/picky/helpers/cache.rb
picky-0.10.4 lib/picky/helpers/cache.rb
picky-0.10.2 lib/picky/helpers/cache.rb
picky-0.10.1 lib/picky/helpers/cache.rb
picky-0.10.0 lib/picky/helpers/cache.rb
picky-0.9.4 lib/picky/helpers/cache.rb
picky-0.9.3 lib/picky/helpers/cache.rb
picky-0.9.2 lib/picky/helpers/cache.rb
picky-0.9.1 lib/picky/helpers/cache.rb
picky-0.9.0 lib/picky/helpers/cache.rb
picky-0.3.0 lib/picky/helpers/cache.rb
picky-0.2.4 lib/picky/helpers/cache.rb
picky-0.2.3 lib/picky/helpers/cache.rb