Class: Shoestring::Cache
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(key, &block) ⇒ Cache
constructor
A new instance of Cache.
Methods inherited from Base
Constructor Details
#initialize(key, &block) ⇒ Cache
Returns a new instance of Cache.
5 6 7 8 |
# File 'lib/shoestring/cache.rb', line 5 def initialize(key, &block) @key = key @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/shoestring/cache.rb', line 3 def block @block end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/shoestring/cache.rb', line 3 def key @key end |
Instance Method Details
#check ⇒ Object
10 11 12 13 |
# File 'lib/shoestring/cache.rb', line 10 def check version = block.call(old_version) File.open(cache_file, 'w') { |f| f.puts(version || 'cached') } end |