Module: Menuconform::Rules::AllergenRules
- Defined in:
- lib/menuconform/rules/allergen_rules.rb
Overview
ALLERGEN-001..002. An explicit empty contains list is a declaration ("we state this has none of the big-9") and satisfies ALLERGEN-001; only a wholly absent allergens object is an enrichment gap.
Class Method Summary collapse
Class Method Details
.call(menu) ⇒ Object
11 12 13 |
# File 'lib/menuconform/rules/allergen_rules.rb', line 11 def call() missing() + contradictions() end |
.contradictions(menu) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/menuconform/rules/allergen_rules.rb', line 22 def contradictions() check = lambda do |entity, type| a = entity["allergens"] return nil unless a both = (a["contains"] || []) & (a["may_contain"] || []) return nil if both.empty? Finding.new("ALLERGEN-002", type, entity["id"], "#{both.join(', ')} declared in both contains and may_contain") end .items_by_id.each_value.filter_map { |it| check.call(it, "item") } + .modifiers_by_id.each_value.filter_map { |m| check.call(m, "modifier") } end |