Class: Hx::Cache
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #each_entry_path(selector) ⇒ Object
- #edit_entry(path, prototype = nil) ⇒ Object
- #get_cache_record ⇒ Object
- #get_entry(path) ⇒ Object
-
#initialize(input, options = {}) ⇒ Cache
constructor
A new instance of Cache.
Methods included from Filter
Methods included from View
Constructor Details
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
278 279 280 |
# File 'lib/hx.rb', line 278 def input @input end |
Instance Method Details
#each_entry_path(selector) ⇒ Object
295 296 297 298 299 300 301 302 303 304 |
# File 'lib/hx.rb', line 295 def each_entry_path(selector) get_cache_record.get_entry_paths do paths = [] @input.each_entry_path(Path::ALL) { |path| paths << path } paths end.each do |path| yield path if selector.accept_path? path end self end |
#edit_entry(path, prototype = nil) ⇒ Object
289 290 291 292 293 |
# File 'lib/hx.rb', line 289 def edit_entry(path, prototype=nil) @input.edit_entry(path, prototype) { |text| yield text } get_cache_record.clear_path(path) self end |
#get_cache_record ⇒ Object
285 286 287 |
# File 'lib/hx.rb', line 285 def get_cache_record (Thread.current[:hx_cache_records] ||= {})[@input] ||= Record.new end |
#get_entry(path) ⇒ Object
306 307 308 |
# File 'lib/hx.rb', line 306 def get_entry(path) get_cache_record.get_entry(path) { @input.get_entry(path) } end |