Class: ActionController::Caching::Fragments::FileStore
- Defined in:
- lib/action_controller/caching.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#delete(name, options) ⇒ Object
:nodoc:.
-
#delete_matched(re, options) ⇒ Object
:nodoc:.
-
#initialize(cache_path) ⇒ FileStore
constructor
A new instance of FileStore.
-
#read(name, options = {}) ⇒ Object
:nodoc:.
-
#write(name, value, options = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(cache_path) ⇒ FileStore
Returns a new instance of FileStore.
337 338 339 |
# File 'lib/action_controller/caching.rb', line 337 def initialize(cache_path) @cache_path = cache_path end |
Instance Method Details
#delete(name, options) ⇒ Object
:nodoc:
352 353 354 |
# File 'lib/action_controller/caching.rb', line 352 def delete(name, ) #:nodoc: File.delete(real_file_path(name)) if File.exist?(real_file_path(name)) end |
#delete_matched(re, options) ⇒ Object
:nodoc:
356 357 358 359 360 361 |
# File 'lib/action_controller/caching.rb', line 356 def delete_matched(re, ) #:nodoc: rootPath = real_file_path([:root_path]) search_dir(@cache_path).each do |f| File.delete(f) if f.index(rootPath) == 0 and f =~ re and File.exist?(f) end end |
#read(name, options = {}) ⇒ Object
:nodoc:
348 349 350 |
# File 'lib/action_controller/caching.rb', line 348 def read(name, = {}) #:nodoc: IO.read(real_file_path(name)) rescue nil end |
#write(name, value, options = {}) ⇒ Object
:nodoc:
341 342 343 344 345 346 |
# File 'lib/action_controller/caching.rb', line 341 def write(name, value, = {}) #:nodoc: ensure_cache_path(File.dirname(real_file_path(name))) File.open(real_file_path(name), "w+") { |f| f.write(value) } rescue => e Base.logger.info "Couldn't create cache directory: #{name} (#{e.})" unless Base.logger.nil? end |