Class: Preflight::Rules::RootHasKeys

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

Overview

ensure the root dict has the specified keys

Instance Method Summary collapse

Constructor Details

#initialize(*keys) ⇒ RootHasKeys

Returns a new instance of RootHasKeys.



9
10
11
# File 'lib/preflight/rules/root_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/root_has_keys.rb', line 13

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