Typecast method extensions for Class class.
Methods
Public Instance methods
Cast on object from another.
String.cast_from(1234) => "1234"
[ show source ]
# File lib/more/facets/typecast.rb, line 160 def cast_from(object) method_to = "to_#{self.name.style(:methodize)}".to_sym if object.respond_to? method_to retval = object.send(method_to) return retval end method_from = "from_#{object.class.name.style(:methodize)}".to_sym if respond_to? method_from retval = send(method_from, object) return retval end raise TypeCastException, "TypeCasting from #{object.class.name} to #{self.name} not supported" end