Class: ActiveMessaging::BaseMessage
- Inherits:
-
Object
- Object
- ActiveMessaging::BaseMessage
- Defined in:
- lib/activemessaging/base_message.rb
Direct Known Subclasses
Adapters::Adapter::Message, Adapters::AmazonSqs::Message, Adapters::Beanstalk::Message, Adapters::Message, Adapters::Sqs::Message, Adapters::Stomp::Message, Adapters::Synch::Message, Adapters::Test::Message, TestMessage
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #dup ⇒ Object
-
#initialize(body = nil, id = nil, headers = {}, destination = nil) ⇒ BaseMessage
constructor
A new instance of BaseMessage.
- #matches_subscription?(subscription) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(body = nil, id = nil, headers = {}, destination = nil) ⇒ BaseMessage
Returns a new instance of BaseMessage.
6 7 8 |
# File 'lib/activemessaging/base_message.rb', line 6 def initialize(body=nil, id=nil, headers={}, destination=nil) @body, @id, @headers, @destination = body, id, headers, destination end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/activemessaging/base_message.rb', line 4 def body @body end |
#destination ⇒ Object
Returns the value of attribute destination.
4 5 6 |
# File 'lib/activemessaging/base_message.rb', line 4 def destination @destination end |
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/activemessaging/base_message.rb', line 4 def headers @headers end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/activemessaging/base_message.rb', line 4 def id @id end |
Instance Method Details
#dup ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/activemessaging/base_message.rb', line 14 def dup super.tap do |copy| [:body, :id, :headers, :destination].each do |field_name| value = send field_name copy.send "#{field_name}=", (value.duplicable? ? value.dup : value) end end end |
#matches_subscription?(subscription) ⇒ Boolean
10 11 12 |
# File 'lib/activemessaging/base_message.rb', line 10 def matches_subscription?(subscription) self.destination.to_s == subscription.destination.value.to_s end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/activemessaging/base_message.rb', line 23 def to_s "<#{self.class.name} id='#{id}' headers='#{headers.inspect}' body='#{body}' >" end |