Class: JunglePath::DBAccess::IO::Insert

Inherits:
Object
  • Object
show all
Includes:
InitDB
Defined in:
lib/jungle_path/db_access/io/insert.rb

Instance Method Summary collapse

Methods included from InitDB

#handle_json_columns, #initialize

Instance Method Details

#_model(model) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# 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