Class: Holotype::CollectionNormalizer
- Inherits:
-
Object
- Object
- Holotype::CollectionNormalizer
- Extended by:
- Memorandum
- Defined in:
- lib/holotype/collection_normalizer.rb,
lib/holotype/collection_normalizer/expected_hash_like_collection_error.rb,
lib/holotype/collection_normalizer/expected_array_like_collection_error.rb
Defined Under Namespace
Classes: ExpectedArrayLikeCollectionError, ExpectedHashLikeCollectionError
Constant Summary collapse
- ARRAY_LIKE_METHODS =
%i[ [] []= ].freeze
- HASH_LIKE_METHODS =
%i[ [] []= keys values ]
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
-
#initialize(definition) ⇒ CollectionNormalizer
constructor
A new instance of CollectionNormalizer.
- #normalize(collection) ⇒ Object
Constructor Details
#initialize(definition) ⇒ CollectionNormalizer
Returns a new instance of CollectionNormalizer.
24 25 26 |
# File 'lib/holotype/collection_normalizer.rb', line 24 def initialize definition @definition = definition end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
22 23 24 |
# File 'lib/holotype/collection_normalizer.rb', line 22 def definition @definition end |
Instance Method Details
#normalize(collection) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/holotype/collection_normalizer.rb', line 28 def normalize collection check_likeness_of collection result = classify normalized collection if definition.immutable? result.freeze else result end end |