Class: FreeMessageQueue::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/fmq/queues/base.rb

Overview

This is the default message implementation in the queue system

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, content_type = "text/plain", created_at = Time.new) ⇒ Message

Create a message item. The payload is often just a string



29
30
31
32
33
34
35
36
37
# File 'lib/fmq/queues/base.rb', line 29

def initialize(payload, content_type = "text/plain", created_at = Time.new)
  @payload = payload
  @created_at = created_at
  @content_type = content_type
  @option = {}
  if block_given? then
    yield self
  end
end

Instance Attribute Details

#content_typeObject

reference to next Message if there is one



22
23
24
# File 'lib/fmq/queues/base.rb', line 22

def content_type
  @content_type
end

#created_atObject

reference to next Message if there is one



22
23
24
# File 'lib/fmq/queues/base.rb', line 22

def created_at
  @created_at
end

#nextObject

reference to next Message if there is one



22
23
24
# File 'lib/fmq/queues/base.rb', line 22

def next
  @next
end

#optionObject

reference to next Message if there is one



22
23
24
# File 'lib/fmq/queues/base.rb', line 22

def option
  @option
end

#payloadObject

reference to next Message if there is one



22
23
24
# File 'lib/fmq/queues/base.rb', line 22

def payload
  @payload
end

Instance Method Details

#bytesObject

Size of item in bytes



40
41
42
# File 'lib/fmq/queues/base.rb', line 40

def bytes
  @payload.size
end