Sha256: 2a675df21de3014eff3542c6f2d47d664470ffd4b7eb34ae41067ecf49773de6

Contents?: true

Size: 430 Bytes

Versions: 10

Compression:

Stored size: 430 Bytes

Contents

module CassandraObject
  module Types
    class SetType
      def encode(set)
        if set.kind_of?(Set)
          set.to_json
        elsif set.kind_of?(Array)
          set.uniq.to_json
        else
          raise ArgumentError.new("#{self} requires an Array or Set")
        end
      end

      def decode(str)
        return str.to_a if str.kind_of?(Set)
        ActiveSupport::JSON.decode(str)
      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/set_type.rb
gotime-cassandra_object-2.4.1 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.4.0 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.6 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.5 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.4 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.3 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.2 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.1 lib/cassandra_object/types/set_type.rb
gotime-cassandra_object-2.3.0 lib/cassandra_object/types/set_type.rb