Class: Cassandra::Types::Frozen

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

Instance Attribute Summary

Attributes inherited from Cassandra::Type

#kind

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

Yield Returns:

  • (String)

    error message to use when assertion fails

Raises:

  • (ArgumentError)

    if the value is not an Array

See Also:



1447
1448
1449
1450
1451
1452
1453
# File 'lib/cassandra/types.rb', line 1447

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: ==



1470
1471
1472
# File 'lib/cassandra/types.rb', line 1470

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

#hashObject



1461
1462
1463
1464
1465
1466
1467
1468
# File 'lib/cassandra/types.rb', line 1461

def hash
  @hash ||= begin
    h = 17
    h = 31 * h + @kind.hash
    h = 31 * h + @value_type.hash
    h
  end
end

#new(*value) ⇒ Array

Coerces the value to Array



1431
1432
1433
1434
1435
1436
1437
1438
# File 'lib/cassandra/types.rb', line 1431

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>".



1457
1458
1459
# File 'lib/cassandra/types.rb', line 1457

def to_s
  "frozen<#{@value_type}>"
end