Class: AttributeConstraint
- Inherits:
-
Object
- Object
- AttributeConstraint
- 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#possible_vals ⇒ Object
readonly
Returns the value of attribute possible_vals.
Instance Method Summary collapse
- #can_be(val, *more) ⇒ Object
-
#initialize(name) ⇒ AttributeConstraint
constructor
A new instance of AttributeConstraint.
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/hosties/Definitions.rb', line 11 def name @name end |
#possible_vals ⇒ Object (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 |