Class: ArMarshalStore::NilFriendlyMarshal
- Inherits:
-
Object
- Object
- ArMarshalStore::NilFriendlyMarshal
- Defined in:
- lib/ar_marshal_store.rb
Constant Summary collapse
- DEFAULT =
ArMarshalStore::NilFriendlyMarshal.new
Class Method Summary collapse
Instance Method Summary collapse
- #dump(str) ⇒ Object
-
#initialize(opts = nil) ⇒ NilFriendlyMarshal
constructor
A new instance of NilFriendlyMarshal.
- #load(str) ⇒ Object
Constructor Details
#initialize(opts = nil) ⇒ NilFriendlyMarshal
Returns a new instance of NilFriendlyMarshal.
3 4 5 6 |
# File 'lib/ar_marshal_store.rb', line 3 def initialize(opts = nil) @opts = opts @opts ||= { :default => Hash.new() } end |
Class Method Details
.dump(str) ⇒ Object
24 25 26 |
# File 'lib/ar_marshal_store.rb', line 24 def self.dump(str) ArMarshalStore::NilFriendlyMarshal::DEFAULT.dump(str) end |
.load(str) ⇒ Object
20 21 22 |
# File 'lib/ar_marshal_store.rb', line 20 def self.load(str) ArMarshalStore::NilFriendlyMarshal::DEFAULT.load(str) end |
Instance Method Details
#dump(str) ⇒ Object
16 17 18 |
# File 'lib/ar_marshal_store.rb', line 16 def dump(str) Marshal.dump(str) end |
#load(str) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/ar_marshal_store.rb', line 8 def load(str) if str.nil? return default_value else Marshal.load(str) || default_value end end |