Module: Philosophal
- Defined in:
- lib/philosophal.rb,
lib/philosophal/types.rb,
lib/philosophal/property.rb,
lib/philosophal/convertor.rb,
lib/philosophal/transform.rb,
lib/philosophal/properties.rb,
lib/philosophal/types/any_type.rb,
lib/philosophal/errors/type_error.rb,
lib/philosophal/properties/schema.rb,
lib/philosophal/types/boolean_type.rb,
lib/philosophal/types/hash_of_type.rb,
lib/philosophal/types/array_of_type.rb,
lib/philosophal/errors/argument_error.rb
Defined Under Namespace
Modules: Properties, Types Classes: ArgumentError, Convertor, Property, Transform, TypeError
Class Method Summary collapse
Class Method Details
.convert(property, value) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/philosophal.rb', line 20 def self.convert(property, value) if property.type === value if property.transform? Transform.make(property.transform, value) else value end else convert_method, subtype = Convertor.convert_method_for(property.type) raise Philosophal::TypeError unless convert_method converted = if subtype Convertor.send(convert_method, value, subtype) else Convertor.send(convert_method, value) end return converted unless property.transform? Transform.make(property.transform, converted) end end |