Class: Believer::Columns::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/believer/columns.rb

Constant Summary collapse

CQL_COL_TYPES =

TYPES = {

:ascii  strings  US-ASCII character string

bigint integers 64-bit signed long blob blobs Arbitrary bytes (no validation), expressed as hexadecimal boolean booleans true or false counter integers Distributed counter value (64-bit long) decimal integers, floats Variable-precision decimal double integers 64-bit IEEE-754 floating point float integers, floats 32-bit IEEE-754 floating point inet strings IP address string in IPv4 or IPv6 format*

int integers  32-bit signed integer

list n/a A collection of one or more ordered elements map n/a A JSON-style array of literals: { literal : literal, literal : literal … } set n/a A collection of one or more elements text strings UTF-8 encoded string timestamp integers, strings Date plus time, encoded as 8 bytes since epoch uuid uuids A UUID in standard UUID format timeuuid uuids Type 1 UUID only (CQL 3) varchar strings UTF-8 encoded string varint integers Arbitrary-precision integer }

{
    :integer => 'INT',
    :string => 'VARCHAR',
    :timestamp => 'TIMESTAMP',
    :float => 'FlOAT'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Column

Returns a new instance of Column.



54
55
56
57
58
59
60
61
62
# File 'lib/believer/columns.rb', line 54

def initialize(opts)
  @name = opts[:name]
  @type = opts[:type]
  raise "Invalid column type #{@type}" unless CQL_COL_TYPES.has_key?(@type)
  @key = opts[:key] == true || !opts[:key].nil?
  if @key && opts[:key].is_a?(Hash)
    @partition_key = opts[:key][:partition_key]
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



52
53
54
# File 'lib/believer/columns.rb', line 52

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



52
53
54
# File 'lib/believer/columns.rb', line 52

def type
  @type
end

Instance Method Details

#cql_column_typeObject



64
65
66
# File 'lib/believer/columns.rb', line 64

def cql_column_type
  CQL_COL_TYPES[@type]
end

#is_key?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/believer/columns.rb', line 68

def is_key?
  @key
end

#is_partition_key?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/believer/columns.rb', line 72

def is_partition_key?
  @partition_key
end