Class: Mendel::ObservableCombiner

Inherits:
Object
  • Object
show all
Includes:
Combiner, Observable
Defined in:
lib/mendel/observable_combiner.rb

Instance Attribute Summary

Attributes included from Combiner

#lists, #priority_queue

Instance Method Summary collapse

Methods included from Combiner

#dump, #dump_json, #each, included, #initialize, #queue_length, #score_combination

Instance Method Details

#notify(*args) ⇒ Object



20
21
22
# File 'lib/mendel/observable_combiner.rb', line 20

def notify(*args)
  changed && notify_observers(*args)
end

#pop_queueObject



12
13
14
15
16
17
18
# File 'lib/mendel/observable_combiner.rb', line 12

def pop_queue
  super.tap { |pair|
    return if pair.nil?
    coords = pair[0].fetch('coordinates')
    notify(:returned, {'coordinates' => coords, 'score' => pair[1]}) unless pair.nil?
  }
end

#queueable_item_for(coordinates) ⇒ Object



8
9
10
# File 'lib/mendel/observable_combiner.rb', line 8

def queueable_item_for(coordinates)
  super.tap {|combo| notify(:scored, combo) }
end