class JunglePath::DBAccess::IO::Update

Public Instance Methods

_model(model) click to toggle source
# File lib/jungle_path/db_access/io/update.rb, line 9
def _model(model)
        update = handle_json_columns(model, model._modified_hash)
        count = update_by_primary_key model, update
        return {update_count: count}
end
_models(model_filter, model_values, confirm=false) click to toggle source
# File lib/jungle_path/db_access/io/update.rb, line 15
def _models(model_filter, model_values, confirm=false)
        ds = @db[model_filter._table_name].where(handle_json_columns(model_filter, model_filter._has_value_hash))
        #puts ds.sql
        #puts "set values: #{model_values._has_value_hash}."
        count = 0
        count = ds.update(handle_json_columns(model_values, model_values._has_value_hash)) if confirm
        return {update_count: count}
end

Private Instance Methods

update_by_primary_key(model, update) click to toggle source
# File lib/jungle_path/db_access/io/update.rb, line 26
def update_by_primary_key model, update
        @db.transaction do
                ds = @db[model._table_name].where(model._primary_key).for_update
                #puts ds.sql
                ds.update update
        end
end