Module: Mafia::Consumer::ClassMethods

Defined in:
lib/mafia/consumer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#routing_keyObject (readonly)

Returns the value of attribute routing_key.



13
14
15
# File 'lib/mafia/consumer.rb', line 13

def routing_key
  @routing_key
end

Instance Method Details

#consume(routing_key) ⇒ Object



15
16
17
# File 'lib/mafia/consumer.rb', line 15

def consume(routing_key)
  @routing_key = routing_key
end

#get_queue_nameObject



28
29
30
31
32
33
# File 'lib/mafia/consumer.rb', line 28

def get_queue_name
  return @queue_name unless @queue_name.nil?
  queue_name = self.name.gsub(/::/, ':')
  queue_name.gsub!(/([^A-Z:])([A-Z])/) { "#{$1}_#{$2}" }
  queue_name.downcase
end

#process(routing_key, *args) ⇒ Object



19
20
21
# File 'lib/mafia/consumer.rb', line 19

def process(routing_key, *args)
  new(routing_key).process(*args)
end

#queue_name(name) ⇒ Object

Explicitly set the queue name



24
25
26
# File 'lib/mafia/consumer.rb', line 24

def queue_name(name)
  @queue_name = name
end