class JunglePath::DBAccess::IO::Insert

Public Instance Methods

_model(model) click to toggle source
# File lib/jungle_path/db_access/io/insert.rb, line 9
def _model(model)
        insert = handle_json_columns(model, model._has_value_hash)
        puts "inserting: #{insert}."
        #@db[model._table_name] << insert
        result = @db[model._table_name].insert(insert)
        if model._primary_key_columns.count == 1
                model._values[model._primary_key_columns.keys.first] = result
        end
        model._secure = false #allow 'secure' columns to be included in hash.
        model = model.class.new(model.to_hash, false) # create a new model instance with all values marked as unmodified.
        model
end