Module: Sneakers::Worker::ClassMethods

Defined in:
lib/sneakers/worker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#queue_nameObject (readonly)

Returns the value of attribute queue_name.



139
140
141
# File 'lib/sneakers/worker.rb', line 139

def queue_name
  @queue_name
end

#queue_optsObject (readonly)

Returns the value of attribute queue_opts.



138
139
140
# File 'lib/sneakers/worker.rb', line 138

def queue_opts
  @queue_opts
end

Instance Method Details

#enqueue(msg, opts = {}) ⇒ Object



146
147
148
149
150
151
152
153
# File 'lib/sneakers/worker.rb', line 146

def enqueue(msg, opts={})
  opts[:routing_key] ||= @queue_opts[:routing_key]
  opts[:content_type] ||= @queue_opts[:content_type]
  opts[:content_encoding] ||= @queue_opts[:content_encoding]
  opts[:to_queue] ||= @queue_name

  publisher.publish(msg, opts)
end

#from_queue(q, opts = {}) ⇒ Object



141
142
143
144
# File 'lib/sneakers/worker.rb', line 141

def from_queue(q, opts={})
  @queue_name = q.to_s
  @queue_opts = opts
end