Class: Magellan::Gcs::Proxy::MessageWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/magellan/gcs/proxy/message_wrapper.rb

Defined Under Namespace

Classes: Attrs, ContextAccessor

Instance Attribute Summary collapse

Instance Method Summary collapse

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.message
  @context = ContextAccessor.new(context)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



7
8
9
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 7

def context
  @context
end

#msgObject (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

#attributesObject



26
27
28
# File 'lib/magellan/gcs/proxy/message_wrapper.rb', line 26

def attributes
  Attrs.new(msg.attributes)
end

#include?(key) ⇒ Boolean

Returns:

  • (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