Class: Believer::Columns::Column
- Inherits:
-
Object
- Object
- Believer::Columns::Column
- Defined in:
- lib/believer/columns.rb
Constant Summary collapse
- CQL_COL_TYPES =
TYPES = {
:ascii strings US-ASCII character stringbigint 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 integerlist 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
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #cql_column_type ⇒ Object
-
#initialize(opts) ⇒ Column
constructor
A new instance of Column.
- #is_key? ⇒ Boolean
- #is_partition_key? ⇒ Boolean
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
52 53 54 |
# File 'lib/believer/columns.rb', line 52 def name @name end |
#type ⇒ Object (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_type ⇒ Object
64 65 66 |
# File 'lib/believer/columns.rb', line 64 def cql_column_type CQL_COL_TYPES[@type] end |
#is_key? ⇒ Boolean
68 69 70 |
# File 'lib/believer/columns.rb', line 68 def is_key? @key end |
#is_partition_key? ⇒ Boolean
72 73 74 |
# File 'lib/believer/columns.rb', line 72 def is_partition_key? @partition_key end |