module JunglePath::Controller::Helpers::Key

Public Class Methods

new(current_identity, params, db, model_class) click to toggle source
Calls superclass method
# File lib/jungle_path/controller/helpers.rb, line 28
def initialize(current_identity, params, db, model_class)
        super(current_identity, params, db, model_class)
end

Public Instance Methods

insert(include_secure_columns: false) click to toggle source
Calls superclass method
# File lib/jungle_path/controller/helpers.rb, line 32
def insert(include_secure_columns: false)
        id = @params[:id]
        key = @db.select._model(@table_class.new({id: id})) if id
        if key #exists already, do update.
                key._consume_hash(@params) # overwrite current values with new values
                @params = key.to_hash # put all in @params for update
                update
                key = @db.select._model(key) # return updated object from database.
        else
                super
        end
end