Class: YDD::SerializationHelper::Base
- Inherits:
-
Object
- Object
- YDD::SerializationHelper::Base
- Defined in:
- lib/ydd/serialization_helper.rb
Instance Attribute Summary collapse
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
Instance Method Summary collapse
- #disable_logger ⇒ Object
- #dump(filename) ⇒ Object
-
#initialize(helper) ⇒ Base
constructor
A new instance of Base.
- #load(filename, truncate = true) ⇒ Object
- #reenable_logger ⇒ Object
Constructor Details
#initialize(helper) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 |
# File 'lib/ydd/serialization_helper.rb', line 7 def initialize(helper) @dumper = helper.dumper @loader = helper.loader @extension = helper.extension end |
Instance Attribute Details
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
5 6 7 |
# File 'lib/ydd/serialization_helper.rb', line 5 def extension @extension end |
Instance Method Details
#disable_logger ⇒ Object
25 26 27 28 |
# File 'lib/ydd/serialization_helper.rb', line 25 def disable_logger @@old_logger = ActiveRecord::Base.logger ActiveRecord::Base.logger = nil end |
#dump(filename) ⇒ Object
13 14 15 16 17 |
# File 'lib/ydd/serialization_helper.rb', line 13 def dump(filename) disable_logger @dumper.dump(File.new(filename, "w")) reenable_logger end |
#load(filename, truncate = true) ⇒ Object
19 20 21 22 23 |
# File 'lib/ydd/serialization_helper.rb', line 19 def load(filename, truncate = true) disable_logger @loader.load(File.new(filename, "r"), truncate) reenable_logger end |
#reenable_logger ⇒ Object
30 31 32 |
# File 'lib/ydd/serialization_helper.rb', line 30 def reenable_logger ActiveRecord::Base.logger = @@old_logger end |