Class: AnyStyle::Dictionary::Marshal
- Inherits:
-
AnyStyle::Dictionary
- Object
- AnyStyle::Dictionary
- AnyStyle::Dictionary::Marshal
- Defined in:
- lib/anystyle/dictionary/marshal.rb
Instance Attribute Summary
Attributes inherited from AnyStyle::Dictionary
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Marshal
constructor
A new instance of Marshal.
- #open ⇒ Object
Methods inherited from AnyStyle::Dictionary
#close, create, #empty?, #get, instance, #open?, #populate!, #put, #tag_counts, #tags, #truncate
Constructor Details
#initialize(options = {}) ⇒ Marshal
Returns a new instance of Marshal.
8 9 10 |
# File 'lib/anystyle/dictionary/marshal.rb', line 8 def initialize( = {}) super(self.class.defaults.merge()) end |
Instance Method Details
#open ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/anystyle/dictionary/marshal.rb', line 12 def open if File.exist?([:path]) @db = ::Marshal.load(File.open([:path])) else @db = {} end self ensure if empty? populate! if File.writable?([:path]) ::Marshal.dump(db, File.open([:path], 'wb')) end end end |