Class: Cassandra::Types::List

Inherits:
Cassandra::Type show all
Defined in:
lib/cassandra/types.rb

Instance Method Summary collapse

Instance Method Details

#assert(value, message = nil, &block) ⇒ void

This method returns an undefined value.

Asserts that a given value is an Array

Parameters:

  • value (Object)

    value to be validated

  • message (String) (defaults to: nil)

    error message to use when assertion fails

Yield Returns:

  • (String)

    error message to use when assertion fails

Raises:

  • (ArgumentError)

    if the value is not an Array

See Also:



759
760
761
762
763
764
765
# File 'lib/cassandra/types.rb', line 759

def assert(value, message = nil, &block)
  Util.assert_instance_of(::Array, value, message, &block)
  value.each do |v|
    Util.assert_type(@value_type, v, message, &block)
  end
  nil
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:



773
774
775
# File 'lib/cassandra/types.rb', line 773

def eql?(other)
  other.is_a?(List) && @value_type == other.value_type
end

#kindSymbol

Returns :list.

Returns:

  • (Symbol)

    :list

See Also:



735
736
737
# File 'lib/cassandra/types.rb', line 735

def kind
  :list
end

#new(*value) ⇒ Array

Coerces the value to Array

Parameters:

  • value (Object)

    original value

Returns:

  • (Array)

    value

See Also:



743
744
745
746
747
748
749
750
# File 'lib/cassandra/types.rb', line 743

def new(*value)
  value = Array(value.first) if value.one?

  value.each do |v|
    Util.assert_type(@value_type, v)
  end
  value
end

#to_sString

Returns "list<type>".

Returns:

  • (String)

    "list<type>"

See Also:



769
770
771
# File 'lib/cassandra/types.rb', line 769

def to_s
  "list<#{@value_type.to_s}>"
end