Class: Shrink::Wrap::Property::Coercion::Enumerable
- Inherits:
-
Object
- Object
- Shrink::Wrap::Property::Coercion::Enumerable
- Includes:
- Support::TypeCheck
- Defined in:
- lib/shrink/wrap/property/coercion/enumerable.rb
Instance Attribute Summary collapse
-
#enumerable ⇒ Object
Returns the value of attribute enumerable.
Instance Method Summary collapse
- #coerce(data) ⇒ Object
-
#initialize(enumerable) ⇒ Enumerable
constructor
A new instance of Enumerable.
Methods included from Support::TypeCheck
#ensure_callable!, #ensure_type!
Constructor Details
#initialize(enumerable) ⇒ Enumerable
Returns a new instance of Enumerable.
12 13 14 15 |
# File 'lib/shrink/wrap/property/coercion/enumerable.rb', line 12 def initialize(enumerable) ensure_type!(::Enumerable, enumerable) self.enumerable = wrap(enumerable.first) end |
Instance Attribute Details
#enumerable ⇒ Object
Returns the value of attribute enumerable.
10 11 12 |
# File 'lib/shrink/wrap/property/coercion/enumerable.rb', line 10 def enumerable @enumerable end |
Instance Method Details
#coerce(data) ⇒ Object
17 18 19 20 21 |
# File 'lib/shrink/wrap/property/coercion/enumerable.rb', line 17 def coerce(data) return coerce_hash(data) if enumerable.size > 1 coerce_enumerable(data) end |