Class: Magellan::Gcs::Proxy::MessageWrapper
- Inherits:
-
Object
- Object
- Magellan::Gcs::Proxy::MessageWrapper
- Defined in:
- lib/magellan/gcs/proxy/message_wrapper.rb
Defined Under Namespace
Classes: Attrs, ContextAccessor
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#msg ⇒ Object
readonly
Returns the value of attribute msg.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #attributes ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(context) ⇒ MessageWrapper
constructor
A new instance of MessageWrapper.
Constructor Details
#initialize(context) ⇒ MessageWrapper
Returns a new instance of MessageWrapper.
8 9 10 11 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 8 def initialize(context) @msg = context. @context = ContextAccessor.new(context) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 7 def context @context end |
#msg ⇒ Object (readonly)
Returns the value of attribute msg.
7 8 9 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 7 def msg @msg end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 13 def [](key) case key.to_sym when :attrs, :attributes then return attributes when :data then return msg.data end context[key.to_sym] end |
#attributes ⇒ Object
26 27 28 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 26 def attributes Attrs.new(msg.attributes) end |
#include?(key) ⇒ Boolean
21 22 23 24 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 21 def include?(key) k = key.to_sym context.include?(k) || [:attrs, :attributes, :data].include?(k) end |