Sha256: 2e4934edf9ee30c28a9350c5c7bc97582902a2ddfcf5dfd7444cc07f465036eb

Contents?: true

Size: 358 Bytes

Versions: 2

Compression:

Stored size: 358 Bytes

Contents

module CouchPotato
  module Persistence
    class TypeCaster
      def cast(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

2 entries across 2 versions & 1 rubygems

Version Path
couch_potato-0.2.19 lib/couch_potato/persistence/type_caster.rb
couch_potato-0.2.18 lib/couch_potato/persistence/type_caster.rb