Sha256: ea5b5e5baa143e9ef94c9d75f101da369f0da61169c9347f32791acc1b54d1f9

Contents?: true

Size: 416 Bytes

Versions: 31

Compression:

Stored size: 416 Bytes

Contents

module Superstore
  module Types
    class StringType < BaseType
      def encode(str)
        raise ArgumentError.new("#{str.inspect} is not a String") unless str.kind_of?(String)

        unless str.encoding == Encoding::UTF_8
          (str.frozen? ? str.dup : str).force_encoding('UTF-8')
        else
          str
        end
      end

      def typecast(value)
        value.to_s
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
superstore-2.4.4 lib/superstore/types/string_type.rb
superstore-2.4.3 lib/superstore/types/string_type.rb
superstore-2.4.2 lib/superstore/types/string_type.rb
superstore-2.4.1 lib/superstore/types/string_type.rb
superstore-2.4.0 lib/superstore/types/string_type.rb
superstore-2.3.0 lib/superstore/types/string_type.rb
superstore-2.2.0 lib/superstore/types/string_type.rb
superstore-2.1.3 lib/superstore/types/string_type.rb
superstore-2.1.2 lib/superstore/types/string_type.rb
superstore-2.1.1 lib/superstore/types/string_type.rb
superstore-2.1.0 lib/superstore/types/string_type.rb
superstore-2.0.1 lib/superstore/types/string_type.rb
superstore-2.0.0 lib/superstore/types/string_type.rb
superstore-1.2.0 lib/superstore/types/string_type.rb
superstore-1.1.4 lib/superstore/types/string_type.rb
superstore-1.1.3 lib/superstore/types/string_type.rb
superstore-1.1.2 lib/superstore/types/string_type.rb
superstore-1.1.1 lib/superstore/types/string_type.rb
superstore-1.1.0 lib/superstore/types/string_type.rb
superstore-1.0.12 lib/superstore/types/string_type.rb