Class: Cassandra::Types::Custom

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Custom

Returns a new instance of Custom.



1173
1174
1175
# File 'lib/cassandra/types.rb', line 1173

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



1171
1172
1173
# File 'lib/cassandra/types.rb', line 1171

def name
  @name
end

Instance Method Details

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

This method returns an undefined value.

Asserts that a given value is of this type

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 invalid



1196
1197
1198
# File 'lib/cassandra/types.rb', line 1196

def assert(value, message = nil, &block)
  raise ::NotImplementedError, "unable to assert a value for custom type: #{@name.inspect}"
end

#kindSymbol

Returns shorthand type name.

Returns:

  • (Symbol)

    shorthand type name



1178
1179
1180
# File 'lib/cassandra/types.rb', line 1178

def kind
  :custom
end

#new(*value) ⇒ Object

Coerces a given value to this type

Parameters:

  • value (*Object)

    value to be coerced

Returns:

  • (Object)

    a value of this type

Raises:

  • (::NotImplementedError)


1186
1187
1188
# File 'lib/cassandra/types.rb', line 1186

def new(*value)
  raise ::NotImplementedError, "unable to create a value for custom type: #{@name.inspect}"
end

#to_sString

Returns a cassandra representation of this type.

Returns:

  • (String)

    a cassandra representation of this type



1201
1202
1203
# File 'lib/cassandra/types.rb', line 1201

def to_s
  "custom: #{@name}"
end