Class BigRecord::ConnectionAdapters::Column
In: lib/big_record/connection_adapters/column.rb
Parent: Object

Column/Attribute Definition

As long as a model has at least one column family set up for it, then columns (a.k.a. model attributes) can then be defined for the model.

The following is an example of a model named book.rb that has a column family called "attribute" set up for it:

  class Book < BigRecord::Base
    column 'attribute:title',   :string
    column :author,             :string
    column :description,        :string
    column :links,              :string,  :collection => true
  end

This simple model defines 4 columns of type string. An important thing to notice here is that the first column ‘attribute:title’ has the column family prepended to it. This is identical to just passing the symbol :title to the column method, and the default behaviour is to prepend the column family (attribute) automatically if one is not defined.

Furthermore, in HBase, there‘s the option of storing collections for a given column. This will return an array for the links attribute on a Book record.

Types and Options

@see BigRecord::Model.column

Methods

Classes and Modules

Module BigRecord::ConnectionAdapters::Column::Format

Constants

COLLECTION_SEPARATOR = "::"

Attributes

alias  [R] 
collection  [R] 
default  [R] 
name  [R] 
primary  [RW] 
type  [R] 

Public Class methods

Used to convert from BLOBs to Strings

Check if the given record is empty. It‘s recursive since it can be an Embedded

Extract the family from a column name

Extract the qualifier from a column name

Extract the collection from the hash, where the positions are the keys. Inspired from ActiveRecord::NestedAttributes.

  params = { 'member' => {
    'name' => 'joe', 'posts_attributes' => {
      '1' => { 'title' => 'Kari, the awesome Ruby documentation browser!' },
      '2' => { 'title' => 'The egalitarian assumption of the modern citizen' },
      'new_67890' => { 'title' => '' } # This one matches the :reject_if proc and will not be instantiated.
    }
  }}

strings are a special case…

Used to convert from Strings to BLOBs

convert something to a boolean

convert something to a BigDecimal

Protected Class methods

Doesn‘t handle time zones.

‘0.123456’ -> 123456 ‘1.123456’ -> 123456

Public Instance methods

Returns the human name of the column name.

Examples
 Column.new('sales_stage', ...).human_name #=> 'Sales stage'

Returns the Ruby class that corresponds to the abstract data type.

callback may be implemented by subclasses if value needs to be ‘massaged’ before instantiation.

Casts value (which is a String) to an appropriate instance.

[Validate]