Method: PCP::Message#initialize
- Defined in:
- lib/pcp/message.rb
#initialize(envelope_or_bytes = {}) ⇒ Object
Construct a new message or decode one
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pcp/message.rb', line 24 def initialize(envelope_or_bytes = {}) @chunks = ['', ''] case envelope_or_bytes when Array # it's bytes decode(envelope_or_bytes) when Hash # it's an envelope default_envelope = {:id => SecureRandom.uuid} @envelope = default_envelope.merge(envelope_or_bytes) else raise ArgumentError, "Unhandled type" end end |