Sha256: b6e15b2ca7ae38f4978e22e9503a8e795788c1a189a78893352b8303e8aacfe6

Contents?: true

Size: 549 Bytes

Versions: 10

Compression:

Stored size: 549 Bytes

Contents

module CassandraObject
  module Types
    class UTF8StringType
      def encode(str)
        # This is technically the most correct, but it is a pain to require utf-8 encoding for all strings. Should revisit.
        #raise ArgumentError.new("#{self} requires a UTF-8 encoded String") unless str.kind_of?(String) && str.encoding == Encoding::UTF_8
        raise ArgumentError.new("#{self} requires a String") unless str.kind_of?(String)
        str.dup
      end

      def decode(str)
        str.force_encoding('UTF-8')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.4.2 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.4.1 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.4.0 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.6 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.5 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.4 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.3 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.2 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.1 lib/cassandra_object/types/utf8_string_type.rb
gotime-cassandra_object-2.3.0 lib/cassandra_object/types/utf8_string_type.rb