Module: Specify::Model::Createable

Overview

Creatable is a mixin that provides the standard #before_create hook for Specify::Model classes.

Most tables in the Specify schema have a Version (an Integer) that is incremented for each modification and a creation timestamp. The #before_create hook will set these.

Instance Method Summary collapse

Instance Method Details

#before_createObject

Initialized the Version to 0 and sets the creation timestamp of a record.



14
15
16
17
18
# File 'lib/specify/models/createable.rb', line 14

def before_create
  self[:Version] = 0
  self[:TimestampCreated] = Time.now
  super
end