Sha256: 6f2ccf985e699f73df2f06005a72889233effb35e6606e040fce97c4711e1de4

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 KB

Contents

--- !ruby/object:RI::ClassDescription 
attributes: []

class_methods: 
- !ruby/object:RI::MethodSummary 
  name: cache
- !ruby/object:RI::MethodSummary 
  name: new
- !ruby/object:RI::MethodSummary 
  name: uncache
comment: 
- !ruby/struct:SM::Flow::H 
  level: 1
  text: CacheDecorator
- !ruby/struct:SM::Flow::P 
  body: CacheDecorator wrap objects to provide cached versions of method calls.
- !ruby/struct:SM::Flow::H 
  level: 2
  text: Usage
- !ruby/struct:SM::Flow::VERB 
  body: "  class X\n    def initialize ; @tick = 0 ; end\n    def tick; @tick + 1; end\n    def cached; @cache ||= CacheDecorator.new(self) ; end\n  end\n\n  x = X.new\n  x.tick  #=> 1\n  x.cached.tick  #=> 2\n  x.tick  #=> 3\n  x.cached.tick  #=> 2\n  x.tick  #=> 4\n  x.cached.tick  #=> 2\n"
- !ruby/struct:SM::Flow::P 
  body: You can also use to cache a collections of objects to gain code speed ups.
- !ruby/struct:SM::Flow::VERB 
  body: "  points = points.collect{|point| Cache.cache(point)}\n"
- !ruby/struct:SM::Flow::P 
  body: "After our algorithm has finished using points, we want to get rid of these Cache objects. That's easy:"
- !ruby/struct:SM::Flow::VERB 
  body: "   points = points.collect{|point| point.self }\n"
- !ruby/struct:SM::Flow::P 
  body: "Or if you prefer (it is ever so slightly safer):"
- !ruby/struct:SM::Flow::VERB 
  body: "   points = points.collect{|point| Cache.uncache(point)}\n"
constants: []

full_name: CacheDecorator
includes: []

instance_methods: 
- !ruby/object:RI::MethodSummary 
  name: method_missing
- !ruby/object:RI::MethodSummary 
  name: self
name: CacheDecorator
superclass: Object

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facets-2.4.2 doc/ri/CacheDecorator/cdesc-CacheDecorator.yaml
facets-2.4.3 doc/ri/CacheDecorator/cdesc-CacheDecorator.yaml