Class: HiddenHippo::Updator
- Inherits:
-
Object
- Object
- HiddenHippo::Updator
- Defined in:
- lib/hidden_hippo/updator.rb
Instance Method Summary collapse
-
#initialize(queue) ⇒ Updator
constructor
A new instance of Updator.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(queue) ⇒ Updator
Returns a new instance of Updator.
6 7 8 |
# File 'lib/hidden_hippo/updator.rb', line 6 def initialize(queue) @queue = queue end |
Instance Method Details
#start ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hidden_hippo/updator.rb', line 10 def start return if @thread @thread = Thread.new do loop do update = @queue.pop break if update == :stop dossier = dossier update.mac_address update.fields.each do |key, value| dossier.public_send(key) << value end begin dossier.save rescue => e puts 'shit' p e end end end end |
#stop ⇒ Object
34 35 36 37 |
# File 'lib/hidden_hippo/updator.rb', line 34 def stop @queue << :stop @thread.join end |