Class: TokyoWrapper::Table
Class Method Summary
collapse
Instance Method Summary
collapse
#all_by_key_value, #all_by_multiple_key_values
#add_has_many_association_id, #all_by_has_many_association_id, #keys_for_belongs_to_association_id, #set_belongs_to_association_id
#convert_comma_separated_values_string_to_array, #convert_params, #convert_values_to_array_for_keys, #convert_values_to_array_for_keys_for_multiple_key_value_hashes
Constructor Details
#initialize(table) ⇒ Table
Returns a new instance of Table.
12
13
14
|
# File 'lib/tokyo_wrapper/table.rb', line 12
def initialize(table)
@table = table
end
|
Class Method Details
.create_with_create_write_non_blocking_lock(file, &block) ⇒ Object
16
17
18
|
# File 'lib/tokyo_wrapper/table.rb', line 16
def self.create_with_create_write_non_blocking_lock(file, &block)
create(file, "cwf", &block)
end
|
.create_with_read_non_locking(file, &block) ⇒ Object
24
25
26
|
# File 'lib/tokyo_wrapper/table.rb', line 24
def self.create_with_read_non_locking(file, &block)
create(file, "re", &block)
end
|
.create_with_write_non_blocking_lock(file, &block) ⇒ Object
20
21
22
|
# File 'lib/tokyo_wrapper/table.rb', line 20
def self.create_with_write_non_blocking_lock(file, &block)
create(file, "wf", &block)
end
|
Instance Method Details
#add(params = {}) ⇒ Object
48
49
50
51
52
|
# File 'lib/tokyo_wrapper/table.rb', line 48
def add(params = {})
id = @table.generate_unique_id
@table[id] = convert_params(params)
id
end
|
#all(options = {}) ⇒ Object
67
68
69
70
|
# File 'lib/tokyo_wrapper/table.rb', line 67
def all(options = {})
result = @table.query
convert_values_to_array_for_keys_for_multiple_key_value_hashes(result, options[:keys_for_has_many_association])
end
|
#close ⇒ Object
44
45
46
|
# File 'lib/tokyo_wrapper/table.rb', line 44
def close
@table.close
end
|
#delete(id) ⇒ Object
63
64
65
|
# File 'lib/tokyo_wrapper/table.rb', line 63
def delete(id)
@table.delete(id.to_s)
end
|
#find(id, options = {}) ⇒ Object
72
73
74
75
76
77
78
79
|
# File 'lib/tokyo_wrapper/table.rb', line 72
def find(id, options = {})
if !options.empty? && options[:pk_included] == true
result = @table[id.to_s].merge({:pk => id.to_s})
else
result = @table[id.to_s]
end
convert_values_to_array_for_keys(result, options[:keys_for_has_many_association])
end
|
#update(id, params) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/tokyo_wrapper/table.rb', line 54
def update(id, params)
if !@table[id.to_s].nil? && !@table[id.to_s].empty?
@table[id.to_s] = @table[id.to_s].merge(convert_params(params))
true
else
false
end
end
|