Class: Maildir::Serializer::Base
- Inherits:
-
Object
- Object
- Maildir::Serializer::Base
- Defined in:
- lib/maildir/serializer/base.rb
Overview
The Maildir::Serializer::Base class reads & writes data to disk as a string. Other serializers (e.g. Maildir::Serializer::Mail) can extend this class to do some pre- and post-processing of the string.
The Serializer API has two methods:
load(path) # => returns data
dump(data, path) # => returns number of bytes written
Instance Method Summary collapse
-
#dump(data, path) ⇒ Object
Writes data to path.
-
#load(path) ⇒ Object
Reads the file at path.
Instance Method Details
#dump(data, path) ⇒ Object
Writes data to path. Returns number of bytes written.
16 17 18 |
# File 'lib/maildir/serializer/base.rb', line 16 def dump(data, path) File.open(path, "w") {|file| file.write(data)} end |
#load(path) ⇒ Object
Reads the file at path. Returns the contents of path.
11 12 13 |
# File 'lib/maildir/serializer/base.rb', line 11 def load(path) File.read(path) end |