Class: Preflight::Rules::InfoHasKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/preflight/rules/info_has_keys.rb

Overview

ensure the info dict has the specified keys

Instance Method Summary collapse

Constructor Details

#initialize(*keys) ⇒ InfoHasKeys

Returns a new instance of InfoHasKeys.



9
10
11
# File 'lib/preflight/rules/info_has_keys.rb', line 9

def initialize(*keys)
  @keys = keys.flatten
end

Instance Method Details

#messages(ohash) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/preflight/rules/info_has_keys.rb', line 13

def messages(ohash)
  info = ohash.object(ohash.trailer[:Info])
  missing = @keys - info.keys
  missing.map { |key|
    "Info dict missing required key #{key}"
  }
end