Class: Shrink::Wrap::Property::Coercion
- Inherits:
-
Object
- Object
- Shrink::Wrap::Property::Coercion
- Defined in:
- lib/shrink/wrap/property/coercion.rb,
lib/shrink/wrap/property/coercion/proc.rb,
lib/shrink/wrap/property/coercion/class.rb,
lib/shrink/wrap/property/coercion/enumerable.rb
Defined Under Namespace
Classes: Class, Enumerable, Proc
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
Instance Method Summary collapse
- #coerce(data) ⇒ Object
-
#initialize(value) ⇒ Coercion
constructor
A new instance of Coercion.
Constructor Details
#initialize(value) ⇒ Coercion
Returns a new instance of Coercion.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/shrink/wrap/property/coercion.rb', line 9 def initialize(value) case value when ::Class self.base = Coercion::Class.new(value) when ::Enumerable self.base = Coercion::Enumerable.new(value) when ::Proc self.base = Coercion::Proc.new(value) else fail!(value) end end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
7 8 9 |
# File 'lib/shrink/wrap/property/coercion.rb', line 7 def base @base end |
Instance Method Details
#coerce(data) ⇒ Object
22 23 24 |
# File 'lib/shrink/wrap/property/coercion.rb', line 22 def coerce(data) base.coerce(data) end |