lib/groonga/record.rb in groonga-0.0.2 vs lib/groonga/record.rb in groonga-0.0.3

- old
+ new

@@ -32,11 +32,11 @@ self.class == other.class and [table, id] == [other.table, other.id] end def [](column_name) - (column(column_name) || {})[@id] + column(column_name, true)[@id] end def []=(column_name, value) column(column_name, true)[@id] = value end @@ -71,10 +71,18 @@ def value=(value) @table[@id] = value end + def increment!(name, delta=nil) + column(name, true).increment!(@id, delta) + end + + def decrement!(name, delta=nil) + column(name, true).decrement!(@id, delta) + end + def columns @table.columns end def attributes @@ -87,9 +95,25 @@ attributes end def delete @table.delete(@id) + end + + def lock(options={}, &block) + @table.lock(options.merge(:id => @id), &block) + end + + def unlock(options={}) + @table.unlock(options.merge(:id => @id)) + end + + def clear_lock(options={}) + @table.clear_lock(options.merge(:id => @id)) + end + + def locked?(options={}) + @table.locked?(options.merge(:id => @id)) end private def column(name, required=false) _column = @table.column(name.to_s)