lib/virtus/coercion/string.rb in virtus-0.0.6 vs lib/virtus/coercion/string.rb in virtus-0.0.7

- old
+ new

@@ -9,9 +9,24 @@ FALSE_VALUES = %w[ 0 f false ].freeze BOOLEAN_MAP = ::Hash[ TRUE_VALUES.product([ true ]) + FALSE_VALUES.product([ false ]) ].freeze NUMERIC_REGEXP = /\A(-?(?:0|[1-9]\d*)(?:\.\d+)?|(?:\.\d+))\z/.freeze + # Coerce give value to a constant + # + # @example + # Virtus::Coercion::String.to_class('String') # => String + # + # @param [String] value + # + # @return [Object] + # + # @api public + def self.to_class(value) + # TODO: add support for namespaced classes like 'Virtus::Attribute::String' + ::Object.const_get(value) + end + # Coerce given value to Time # # @example # Virtus::Coercion::String.to_time(string) # => Time object #