Class: Cequel::Schema::TableProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/cequel/schema/table_property.rb

Overview

Encapsulates a CQL3 storage property defined on a table

Since:

  • 1.0.0

Direct Known Subclasses

MapProperty

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ TableProperty

Returns a new instance of TableProperty.

Parameters:

  • name (Symbol)

    name of the property

  • value

    value of the property

Since:

  • 1.0.0



33
34
35
36
# File 'lib/cequel/schema/table_property.rb', line 33

def initialize(name, value)
  @name = name
  self.normalized_value = value
end

Instance Attribute Details

#nameSymbol (readonly)

Returns name of the property.

Returns:

  • (Symbol)

    name of the property

Since:

  • 1.0.0



9
10
11
# File 'lib/cequel/schema/table_property.rb', line 9

def name
  @name
end

#valueObject (readonly)

Returns value of the property.

Returns:

  • value of the property

Since:

  • 1.0.0



11
12
13
# File 'lib/cequel/schema/table_property.rb', line 11

def value
  @value
end

Class Method Details

.build(name, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize an instance of the appropriate TableProperty implementation.

Parameters:

  • name (Symbol)

    name of the property

  • value

    value of the property

Since:

  • 1.0.0



19
20
21
22
23
24
25
26
27
# File 'lib/cequel/schema/table_property.rb', line 19

def self.build(name, value)
  clazz =
    case name.to_sym
    when :compaction then CompactionProperty
    when :compression then CompressionProperty
    else TableProperty
    end
  clazz.new(name, value)
end

Instance Method Details

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

Returns true iff ‘self` and `other` logically equivalent (same value for same property).

Since:

  • 1.0.0



50
51
52
53
# File 'lib/cequel/schema/table_property.rb', line 50

def ==(other)
  other.name == self.name &&
    other.value == self.value
end

#hashObject

Returns a hash code for this object

Since:

  • 1.0.0



57
58
59
# File 'lib/cequel/schema/table_property.rb', line 57

def hash
  [name, value].hash
end

#to_cqlString

Returns CQL fragment defining this property in a ‘CREATE TABLE` statement.

Returns:

  • (String)

    CQL fragment defining this property in a ‘CREATE TABLE` statement

Since:

  • 1.0.0



43
44
45
# File 'lib/cequel/schema/table_property.rb', line 43

def to_cql
  "#{@name} = #{value_cql}"
end