Sha256: eabb7ee3f837efe7f2361fb93b6e69317c47d80d39b355ef571f6b16953a06ea

Contents?: true

Size: 370 Bytes

Versions: 1

Compression:

Stored size: 370 Bytes

Contents

module Superstore
  module Types
    class StringType < ActiveModel::Type::Value
      def serialize(str)
        return if str.nil?

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

      def cast_value(value)
        value.to_s
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-2.5.0 lib/superstore/types/string_type.rb