Class: Mutual::Messaging::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/messaging/task_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Task

Returns a new instance of Task.

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
# File 'lib/messaging/task_manager.rb', line 27

def initialize(options)
  properties = options.values_at(:task_id, :type, :name, :body)
  raise ArgumentError unless properties.all? {|p| p != nil }
  @task_id, @type, @name, @body = properties
  @return_address = options[:return_address]
  @queue = "tasks.#{@type}"
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



26
27
28
# File 'lib/messaging/task_manager.rb', line 26

def queue
  @queue
end

#return_addressObject (readonly)

Returns the value of attribute return_address.



26
27
28
# File 'lib/messaging/task_manager.rb', line 26

def return_address
  @return_address
end

#task_idObject (readonly)

Returns the value of attribute task_id.



26
27
28
# File 'lib/messaging/task_manager.rb', line 26

def task_id
  @task_id
end

Instance Method Details

#marshalObject



35
36
37
38
39
40
41
42
43
# File 'lib/messaging/task_manager.rb', line 35

def marshal
  hash = {
    :task_id => @task_id,
    :name => @name,
    :body => @body
  }
  hash[:return_address] = @return_address if @return_address
  hash
end

#to_json(*args) ⇒ Object



45
46
47
# File 'lib/messaging/task_manager.rb', line 45

def to_json(*args)
  marshal.to_json(*args)
end