Module: Playbook::Props

Extended by:
ActiveSupport::Concern
Included in:
KitBase
Defined in:
lib/playbook/props.rb,
lib/playbook/props/base.rb,
lib/playbook/props/date.rb,
lib/playbook/props/enum.rb,
lib/playbook/props/hash.rb,
lib/playbook/props/proc.rb,
lib/playbook/props/array.rb,
lib/playbook/props/number.rb,
lib/playbook/props/string.rb,
lib/playbook/props/boolean.rb,
lib/playbook/props/numeric.rb,
lib/playbook/props/hash_array.rb,
lib/playbook/props/percentage.rb,
lib/playbook/props/nested_props.rb,
lib/playbook/props/number_array.rb

Defined Under Namespace

Classes: Array, Base, Boolean, Date, Enum, Error, HashArray, HashProp, NestedProps, Number, NumberArray, Numeric, Percentage, Proc, String

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valuesObject

Returns the value of attribute values.



26
27
28
# File 'lib/playbook/props.rb', line 26

def values
  @values
end

Instance Method Details

#initialize(prop_values = {}, &block) ⇒ Object



29
30
31
32
33
34
# File 'lib/playbook/props.rb', line 29

def initialize(prop_values = {}, &block)
  self.values = { children: block }.merge(Hash(prop_values))
  self.class.props.each do |key, definition|
    definition.validate! values[key]
  end
end

#prop(name) ⇒ Object



36
37
38
# File 'lib/playbook/props.rb', line 36

def prop(name)
  self.class.props[name].value values[name]
end