Class: FuQueue

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

Overview

FuQueue

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_name) ⇒ FuQueue

Returns a new instance of FuQueue.



9
10
11
# File 'lib/fu_queue.rb', line 9

def initialize(queue_name)
  @sm_queue = SMQueue.new(YAML.load_file("#{RAILS_ROOT}/config/fu_queue.yml")[RAILS_ENV][queue_name.to_s])
end

Class Method Details

.[](queue_name) ⇒ Object



4
5
6
# File 'lib/fu_queue.rb', line 4

def [](queue_name)
  ( @queues ||= {} )[queue_name] ||= new(queue_name)
end

Instance Method Details

#getObject



13
14
15
16
17
18
19
20
21
# File 'lib/fu_queue.rb', line 13

def get
  if block_given?
    @sm_queue.get do |message|
      yield YAML.parse(message.body).transform
    end
  else
    YAML.parse(@sm_queue.get.body).transform
  end
end

#put(message) ⇒ Object



23
24
25
# File 'lib/fu_queue.rb', line 23

def put(message)
  @sm_queue.put(message.to_yaml)
end