Class: Playbook::Props::NestedProps

Inherits:
Base
  • Object
show all
Defined in:
lib/playbook/props/nested_props.rb

Instance Attribute Summary

Attributes inherited from Base

#default, #deprecated, #kit, #name, #required

Instance Method Summary collapse

Methods inherited from Base

#validate!, #value

Constructor Details

#initialize(nested_kit:, **kwargs) ⇒ NestedProps

Returns a new instance of NestedProps.



6
7
8
9
# File 'lib/playbook/props/nested_props.rb', line 6

def initialize(nested_kit:, **kwargs)
  super(**kwargs)
  @nested_kit = nested_kit
end

Instance Method Details

#validate(values) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/playbook/props/nested_props.rb', line 11

def validate(values)
  return true if values.nil?

  @nested_kit.props.each do |prop_key, definition|
    definition.validate! definition.value(values[prop_key])
  end
  true
rescue Playbook::Props::Error
  false
end