app/models/internal_id.rb
# Generates next internal id and returns it
# init: Block that gets called to initialize InternalId record if not present
#       Make sure to not throw exceptions in the absence of records (if this is expected).
Generates next internal id and returns it
init: Block that gets called to initialize InternalId record if not present
Make sure to not throw exceptions in the absence of records (if this is expected).
Generates next internal id and returns it init : Block that gets called to initialize InternalId record if not present Make sure to not throw exceptions in the absence of records ( if this is expected ) .
def generate(init)
      subject.transaction do
         Note this will acquire a ROW SHARE lock on the InternalId record
        (lookup || create_record(init)).increment_and_save!
      end
    end
def generate ( init ) subject . transaction do ( lookup || create_record ( init ) ) . increment_and_save! end end
Generates next internal id and returns it
init: Block that gets called to initialize InternalId record if not present
Make sure to not throw exceptions in the absence of records (if this is expected).
Generates next internal id and returns it init : Block that gets called to initialize InternalId record if not present Make sure to not throw exceptions in the absence of records ( if this is expected ) .
# Create a record in internal_ids if one does not yet exist # and increment its last value # # Note this will acquire a ROW SHARE lock on the InternalId record
init
<not_specific>