Sha256: 3dbca2f369103aaf15bcae5ce2bc845068dc3c386035c8f4aa0e53231e6f6a54
Contents?: true
Size: 792 Bytes
Versions: 4
Compression:
Stored size: 792 Bytes
Contents
module CouchPotato module Persistence class TypeCaster #:nodoc: def cast(value, type) if type == :boolean cast_boolen(value) else cast_native(value, type) end end private def cast_boolen(value) if [FalseClass, TrueClass].include?(value.class) || value.nil? value elsif [0, '0'].include?(value) false else true end end def cast_native(value, type) if type && !value.instance_of?(type) if type == Fixnum value.to_s.scan(/\d/).join.to_i unless value.blank? else type.json_create value end else value end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems