Class: Foxy::FileCache
Class Attribute Summary collapse
-
.nocache ⇒ Object
Returns the value of attribute nocache.
Class Method Summary collapse
- .html(*path, &block) ⇒ Object
- .html!(*path, &block) ⇒ Object
- .json(*path) ⇒ Object
- .json!(*path) ⇒ Object
- .nocache!(reason = nil) ⇒ Object
- .raw(*path, &block) ⇒ Object
- .raw!(*path, &block) ⇒ Object
- .yaml(*path) ⇒ Object
- .yaml!(*path) ⇒ Object
Instance Method Summary collapse
-
#initialize(*path) ⇒ FileCache
constructor
A new instance of FileCache.
Constructor Details
#initialize(*path) ⇒ FileCache
Returns a new instance of FileCache.
75 76 77 |
# File 'lib/foxy/file_cache.rb', line 75 def initialize(*path) @path = path end |
Class Attribute Details
.nocache ⇒ Object
Returns the value of attribute nocache.
6 7 8 |
# File 'lib/foxy/file_cache.rb', line 6 def nocache @nocache end |
Class Method Details
.html(*path, &block) ⇒ Object
14 15 16 |
# File 'lib/foxy/file_cache.rb', line 14 def html(*path, &block) cache path, "html", &block end |
.html!(*path, &block) ⇒ Object
30 31 32 |
# File 'lib/foxy/file_cache.rb', line 30 def html!(*path, &block) cache! path, "html", &block end |
.json(*path) ⇒ Object
22 23 24 |
# File 'lib/foxy/file_cache.rb', line 22 def json(*path) JSON[cache(path, "json") { JSON[yield] }] end |
.json!(*path) ⇒ Object
38 39 40 |
# File 'lib/foxy/file_cache.rb', line 38 def json!(*path) JSON[cache!(path, "json") { JSON[yield] }] end |
.nocache!(reason = nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/foxy/file_cache.rb', line 8 def nocache!(reason = nil) self.nocache = true puts "NO CACHE: #{reason}" binding.pry end |
.raw(*path, &block) ⇒ Object
18 19 20 |
# File 'lib/foxy/file_cache.rb', line 18 def raw(*path, &block) cache path, "txt", &block end |
.raw!(*path, &block) ⇒ Object
34 35 36 |
# File 'lib/foxy/file_cache.rb', line 34 def raw!(*path, &block) cache! path, "txt", &block end |
.yaml(*path) ⇒ Object
26 27 28 |
# File 'lib/foxy/file_cache.rb', line 26 def yaml(*path) YAML.load(cache(path, "yaml") { YAML.dump(yield) }) end |
.yaml!(*path) ⇒ Object
42 43 44 |
# File 'lib/foxy/file_cache.rb', line 42 def yaml!(*path) YAML.load(cache!(path, "yaml") { YAML.dump(yield) }) end |