AttributesClass
- Namespace
- Ancestors
-
-
Enumerable
Object
-
Keeps track of the structure of the attributes associated with a Value object. This is an ordered set of #required, #optional, #splat, and #block arguments to the value object’s initialize method, some or all of which may be #comparable.
Constructor
initialize(firstSymbol, Array<
Symbol, Object>
, *restArray<
Symbol, Array<
Symbol, Object>>
, optionsHash = {}
)#⚙
Sets up a Value objects attributes first and rest. If the last attribute starts with ‘&’, then the value object’s initialize method may take an optional block. If the last or second to last, depending on the previous sentence, attribute starts with ‘*’, then the value object’s initialize method may take a splat argument. The rest of the attributes are split at the first element that’s an Array. All attributes before this element are required arguments to the value object’s initialize method. The first element that’s an Array and all following elements, which should also be Arrays, are optional arguments to the value object’s initialize method, where the first element of these Arrays is the attribute and the last element is its default value.
- Options
-
- :comparableArray
<
Symbol>
, Boolean, nil =nil
-
The subset of first and rest that should be used for comparing instances of this value object class, or a truthy value to use the whole set, or a falsy value to use an empty set
- :comparableArray
- RaisesArgumentError
-
If any element of comparable isn’t an element of first and rest
Instance Methods
each{ |attributeSymbol| … }self#⚙
Enumerates the attributes.
eachEnumerator<
Symbol>
#⚙
Returns an Enumerator over the attributes.
==
(otherAttributes)Boolean#⚙
Returns true if the receiver’s class and its required, optional,
splat, and block attributes #==
those of other.
requiredArray<
Symbol>
#⚙
Returns the required attributes.
optionalArray<
Array<
Symbol, Object>>
#⚙
Returns the optional attributes and their defaults.
splatSymbol?#⚙
Returns the splat attribute.
blockSymbol?#⚙
Returns the block attribute.
comparableArray<
Symbol>
#⚙
Returns the comparable attributes.