Class: MessageCoder
- Inherits:
-
Object
- Object
- MessageCoder
- Defined in:
- lib/pipeline_toolkit/message_coder.rb
Overview
Encodes messages
Class Method Summary collapse
Class Method Details
.decode(str) ⇒ Object
14 15 16 17 |
# File 'lib/pipeline_toolkit/message_coder.rb', line 14 def self.decode(str) str.gsub!('--\\n', "\n") Marshal.load(str) end |
.encode(msg) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/pipeline_toolkit/message_coder.rb', line 6 def self.encode(msg) # NB: Using Marshal here because it's 9-10x faster than to_yaml # See http://gist.github.com/190849 str = Marshal.dump(msg) str.gsub!("\n", '--\\n') str end |