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



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

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



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

def name
  @name
end

#valueObject (readonly)

Returns value of the property.

Returns:

  • value of the property

Since:

  • 1.0.0



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

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



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

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

#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



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

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