Class: Magellan::Gcs::Proxy::MessageWrapper::Attrs
- Inherits:
-
Object
- Object
- Magellan::Gcs::Proxy::MessageWrapper::Attrs
- Defined in:
- lib/magellan/gcs/proxy/message_wrapper.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(data) ⇒ Attrs
constructor
A new instance of Attrs.
Constructor Details
#initialize(data) ⇒ Attrs
Returns a new instance of Attrs.
57 58 59 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 57 def initialize(data) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
56 57 58 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 56 def data @data end |
Instance Method Details
#[](key) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 61 def [](key) value = data[key] if value.is_a?(String) && value =~ /\A\[.*\]\z|\A\{.*\}\z/ begin JSON.parse(value) rescue value end else value end end |
#include?(key) ⇒ Boolean
74 75 76 |
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 74 def include?(key) data.include?(key) || data.include?(key.to_sym) end |