Class: Hx::Interop::Message
- Inherits:
-
Object
- Object
- Hx::Interop::Message
- Defined in:
- lib/interop/message.rb
Overview
Represents a single interop message, with headers and a body.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #decode(decoder = ContentType::STANDARD) ⇒ Object
- #dup ⇒ Object
-
#initialize(headers = nil, body = nil) ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize(headers = nil, body = nil) ⇒ Message
38 39 40 41 |
# File 'lib/interop/message.rb', line 38 def initialize(headers = nil, body = nil) @headers = Headers.new(headers) self.body = body unless body.nil? end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
36 37 38 |
# File 'lib/interop/message.rb', line 36 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
36 37 38 |
# File 'lib/interop/message.rb', line 36 def headers @headers end |
Class Method Details
.build(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/interop/message.rb', line 8 def build(*args) return args.first if args.one? && args.first.is_a?(Message) new.tap do || args.each do |arg| assign_build_arg , arg end end end |
Instance Method Details
#[](key) ⇒ Object
43 44 45 |
# File 'lib/interop/message.rb', line 43 def [](key) @headers[key] end |
#[]=(key, value) ⇒ Object
47 48 49 |
# File 'lib/interop/message.rb', line 47 def []=(key, value) @headers[key] = value end |
#decode(decoder = ContentType::STANDARD) ⇒ Object
56 57 58 |
# File 'lib/interop/message.rb', line 56 def decode(decoder = ContentType::STANDARD) decoder.decode self end |
#dup ⇒ Object
60 61 62 |
# File 'lib/interop/message.rb', line 60 def dup Message.new headers.to_h, body.dup end |