Class: Humidifier::Props::Prop

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/props.rb

Overview

Superclass for all CFN properties

Constant Summary collapse

WHITELIST =

The list of classes that are valid beyond the normal values for each prop

[Fn, Ref].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, spec = {}) ⇒ Prop

Returns a new instance of Prop.



13
14
15
16
17
# File 'lib/humidifier/props.rb', line 13

def initialize(key, spec = {})
  @key  = key
  @name = key.underscore
  @spec = spec
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



11
12
13
# File 'lib/humidifier/props.rb', line 11

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/humidifier/props.rb', line 11

def name
  @name
end

#specObject (readonly)

Returns the value of attribute spec.



11
12
13
# File 'lib/humidifier/props.rb', line 11

def spec
  @spec
end

Class Method Details

.allow_type(*types) ⇒ Object



49
50
51
52
# File 'lib/humidifier/props.rb', line 49

def allow_type(*types)
  allowed_types
  @allowed_types += types
end

.allowed_typesObject



45
46
47
# File 'lib/humidifier/props.rb', line 45

def allowed_types
  @allowed_types ||= [Fn, Ref]
end

Instance Method Details

#documentationObject

the link to the AWS docs



20
21
22
# File 'lib/humidifier/props.rb', line 20

def documentation
  spec["Documentation"]
end

#required?Boolean

true if this property is required by the resource

Returns:

  • (Boolean)


25
26
27
# File 'lib/humidifier/props.rb', line 25

def required?
  spec["Required"]
end

#to_cf(value) ⇒ Object

CFN stack syntax



30
31
32
# File 'lib/humidifier/props.rb', line 30

def to_cf(value)
  [key, Serializer.dump(value)]
end

#update_typeObject

the type of update that occurs when this property is updated on its associated resource



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

def update_type
  spec["UpdateType"]
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/humidifier/props.rb', line 40

def valid?(value)
  self.class.allowed_types.any? { |type| value.is_a?(type) }
end