Class: ShallowAttributes::Type::String Abstract
- Inherits:
-
Object
- Object
- ShallowAttributes::Type::String
- Defined in:
- lib/shallow_attributes/type/string.rb
Overview
This class is abstract.
Abstract class for typecast object to String type.
Instance Method Summary collapse
-
#coerce(value, options = {}) ⇒ Sting
Convert value to String type.
Instance Method Details
#coerce(value, options = {}) ⇒ Sting
Convert value to String type
23 24 25 26 27 28 29 30 |
# File 'lib/shallow_attributes/type/string.rb', line 23 def coerce(value, = {}) case value when ::Array then value.join when ::Hash, ::Class then error(value) else value.respond_to?(:to_s) ? value.to_s : error(value) end end |