Class: EnoughFields::MonitSet

Inherits:
Set
  • Object
show all
Defined in:
lib/enough_fields/monit_set.rb

Instance Method Summary collapse

Instance Method Details

#check_notificationsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/enough_fields/monit_set.rb', line 19

def check_notifications
  results = {}
  self.each do |attribute_value|
    results[ [attribute_value.call_stack, attribute_value.klass] ] ||= []
    results[ [attribute_value.call_stack, attribute_value.klass] ] << Result.new(attribute_value.field, attribute_value.used?)
  end
  results.each do |call_stack_klass, results|
    call_stack, klass = *call_stack_klass
    if results.find { |result| !result.used? }
      EnoughFields.add_notification(call_stack, klass, results.find_all { |result| result.used? }.collect(&:field))
    end
  end
end