Module: OkHbase::Concerns::Row
- Included in:
- Row
- Defined in:
- lib/ok_hbase/concerns/row.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ok_hbase/concerns/row.rb', line 43
def method_missing(method, *arguments, &block)
if method.to_s[-1, 1] == '='
key = method[0...-1]
val = arguments.last
unless key.to_s.include? ':'
key = "#{default_column_family}:#{key}"
else
end
ret_val = raw_data[key] = val
ret_val
else
unless method.to_s.include? ':'
key = "#{default_column_family}:#{method}"
else
end
return raw_data[key]
end
end
|
Instance Attribute Details
#default_column_family ⇒ Object
Returns the value of attribute default_column_family.
4
5
6
|
# File 'lib/ok_hbase/concerns/row.rb', line 4
def default_column_family
@default_column_family
end
|
#raw_data ⇒ Object
Returns the value of attribute raw_data.
5
6
7
|
# File 'lib/ok_hbase/concerns/row.rb', line 5
def raw_data
@raw_data
end
|
#row_key ⇒ Object
Returns the value of attribute row_key.
4
5
6
|
# File 'lib/ok_hbase/concerns/row.rb', line 4
def row_key
@row_key
end
|
#table ⇒ Object
Returns the value of attribute table.
4
5
6
|
# File 'lib/ok_hbase/concerns/row.rb', line 4
def table
@table
end
|
#timestamp ⇒ Object
Returns the value of attribute timestamp.
4
5
6
|
# File 'lib/ok_hbase/concerns/row.rb', line 4
def timestamp
@timestamp
end
|
Instance Method Details
#attributes ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/ok_hbase/concerns/row.rb', line 19
def attributes
hash = Hash[@raw_data.keys.map do |k|
k = k.split(':', 2).last
key_value = [k, send(k)]
key_value
end
].with_indifferent_access
hash[:row_key] = @row_key
hash
end
|
#delete ⇒ Object
38
39
40
|
# File 'lib/ok_hbase/concerns/row.rb', line 38
def delete
table.delete(row_key)
end
|
#encoded_data ⇒ Object
15
16
17
|
# File 'lib/ok_hbase/concerns/row.rb', line 15
def encoded_data
Hash[@raw_data.map { |k, v| [k, _encode(v)] }].with_indifferent_access
end
|
#id ⇒ Object
7
8
9
|
# File 'lib/ok_hbase/concerns/row.rb', line 7
def id
self.row_key
end
|
#id=(val) ⇒ Object
11
12
13
|
# File 'lib/ok_hbase/concerns/row.rb', line 11
def id=(val)
self.row_key = val
end
|
#save! ⇒ Object
32
33
34
35
36
|
# File 'lib/ok_hbase/concerns/row.rb', line 32
def save!()
table.put(row_key, encoded_data, timestamp)
end
|