Class: Preflight::Rules::InfoHasKeys
- Inherits:
-
Object
- Object
- Preflight::Rules::InfoHasKeys
- Defined in:
- lib/preflight/rules/info_has_keys.rb
Overview
ensure the info dict has the specified keys
Instance Method Summary collapse
-
#initialize(*keys) ⇒ InfoHasKeys
constructor
A new instance of InfoHasKeys.
- #messages(ohash) ⇒ Object
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 (ohash) info = ohash.object(ohash.trailer[:Info]) missing = @keys - info.keys missing.map { |key| "Info dict missing required key #{key}" } end |