Class: AttributeConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/hosties/Definitions.rb

Overview

Constrains a named attribute to a provided set of values. This is good for things like describing environments that a set of hosts can be in, for instance Dev, QA, etc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ AttributeConstraint

Returns a new instance of AttributeConstraint.



13
14
15
16
# File 'lib/hosties/Definitions.rb', line 13

def initialize(name)
  @name = name
  @possible_vals = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/hosties/Definitions.rb', line 11

def name
  @name
end

#possible_valsObject (readonly)

Returns the value of attribute possible_vals.



11
12
13
# File 'lib/hosties/Definitions.rb', line 11

def possible_vals
  @possible_vals
end

Instance Method Details

#can_be(val, *more) ⇒ Object



18
19
20
# File 'lib/hosties/Definitions.rb', line 18

def can_be(val, *more)
  @possible_vals += (more << val)
end