Class: FluidFeatures::Persistence::Storage
- Inherits:
-
Object
- Object
- FluidFeatures::Persistence::Storage
- Defined in:
- lib/fluidfeatures/persistence/storage.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#store ⇒ Object
Returns the value of attribute store.
Instance Method Summary collapse
- #file_size ⇒ Object
-
#initialize(config, logger = nil) ⇒ Storage
constructor
A new instance of Storage.
- #path ⇒ Object
Constructor Details
#initialize(config, logger = nil) ⇒ Storage
Returns a new instance of Storage.
8 9 10 11 12 13 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 8 def initialize(config, logger=nil) @dir = config["dir"] @logger = logger || Logger.new(STDERR) @file_name = "#{self.class.to_s.split('::').last.downcase}.pstore" FileUtils.mkpath(dir) unless Dir.exists?(dir) end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
6 7 8 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 6 def dir @dir end |
#file_name ⇒ Object
Returns the value of attribute file_name.
6 7 8 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 6 def file_name @file_name end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 6 def logger @logger end |
#store ⇒ Object
Returns the value of attribute store.
6 7 8 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 6 def store @store end |
Instance Method Details
#file_size ⇒ Object
23 24 25 26 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 23 def file_size # TODO: rescue should return nil here File.size(path) rescue 0 end |
#path ⇒ Object
19 20 21 |
# File 'lib/fluidfeatures/persistence/storage.rb', line 19 def path File.join(dir, file_name) end |