Class: OkHbase::ActiveModel

Inherits:
Row
  • Object
show all
Includes:
Concerns::CustomRow::ClassMethods, Concerns::Indexable::ClassMethods, Concerns::Table::ClassMethods, Concerns::Table::Instrumentation
Defined in:
lib/ok_hbase/active_model.rb

Instance Attribute Summary

Attributes included from Concerns::Row

#default_column_family, #raw_data, #row_key, #table, #timestamp

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Row

#attributes, #encoded_data, #id, #id=, #method_missing, #save!

Constructor Details

#initialize(raw_data = {}) ⇒ ActiveModel

Returns a new instance of ActiveModel.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ok_hbase/active_model.rb', line 11

def initialize(raw_data={})

  raw_data = raw_data.with_indifferent_access
  raw_data = raw_data[:raw_data] if raw_data[:raw_data]


  options = {
      table: self.class,
      default_column_family: self.class.default_column_family,
      raw_data: raw_data,
  }
  super(options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OkHbase::Concerns::Row

Class Method Details

.create(raw_data = {}) ⇒ Object



25
26
27
28
29
# File 'lib/ok_hbase/active_model.rb', line 25

def self.create(raw_data={})
  instance = new(raw_data)
  instance.save!
  instance
end

Instance Method Details

#delete(indexes = []) ⇒ Object



31
32
33
# File 'lib/ok_hbase/active_model.rb', line 31

def delete(indexes=[])
  self.class.delete(row_key, nil, nil, indexes)
end