class Cassandra::Types::Set

Attributes

value_type[R]

@private

Public Class Methods

new(value_type) click to toggle source

@private

Calls superclass method Cassandra::Type::new
    # File lib/cassandra/types.rb
765 def initialize(value_type)
766   super(:set)
767   @value_type = value_type
768 end

Public Instance Methods

==(other)
Alias for: eql?
assert(value, message = nil, &block) click to toggle source

Asserts that a given value is an Set @param value [Object] value to be validated @param message [String] error message to use when assertion fails @yieldreturn [String] error message to use when assertion fails @raise [ArgumentError] if the value is not an Set @return [void] @see Cassandra::Type#assert

    # File lib/cassandra/types.rb
817 def assert(value, message = nil, &block)
818   Util.assert_instance_of(::Set, value, message, &block)
819   value.each do |v|
820     Util.assert_type(@value_type, v, message, &block)
821   end
822   nil
823 end
eql?(other) click to toggle source
    # File lib/cassandra/types.rb
840 def eql?(other)
841   other.is_a?(Set) && @value_type == other.value_type
842 end
Also aliased as: ==
hash() click to toggle source
    # File lib/cassandra/types.rb
831 def hash
832   @hash ||= begin
833     h = 17
834     h = 31 * h + @kind.hash
835     h = 31 * h + @value_type.hash
836     h
837   end
838 end
new(*value) click to toggle source

Coerces the value to Set @param value [Object] original value @return [Set] value @see Cassandra::Type#new @example Creating a set using splat arguments

include Cassandra::Types

set(varchar).new('Jane', 'Alice', 'Loren') => #<Set: {"Jane", "Alice", "Loren"}>

@example Coercing an existing set

include Cassandra::Types

set(varchar).new(Set['Jane', 'Alice', 'Loren']) => #<Set: {"Jane", "Alice", "Loren"}>

@example Coercing an array

include Cassandra::Types

set(varchar).new(['Jane', 'Alice', 'Loren']) => #<Set: {"Jane", "Alice", "Loren"}>
    # File lib/cassandra/types.rb
788 def new(*value)
789   value = value.first if value.one?
790 
791   case value
792   when ::Array
793     result = ::Set.new
794     value.each do |v|
795       Util.assert_type(@value_type, v)
796       result << v
797     end
798     result
799   when ::Set
800     value.each do |v|
801       Util.assert_type(@value_type, v)
802     end
803     value
804   else
805     Util.assert_type(@value_type, value)
806     ::Set[value]
807   end
808 end
to_s() click to toggle source

@return [String] `“set<type>”` @see Cassandra::Type#to_s

    # File lib/cassandra/types.rb
827 def to_s
828   "set<#{@value_type}>"
829 end