app/models/concerns/oid_generator.rb
# Callback that assigns the oid. This should never be called directly.
Callback that assigns the oid. This should never be called directly.
Callback that assigns the oid . This should never be called directly .
def assign_oid
    if version > 1
      parent_oid = self.class.where(version_independent_id: version_independent_id, version: 1)
                       .limit(1)
                       .pluck(:oid)
                       .first
      if parent_oid != oid && !parent_oid.blank?
        update_attribute(:oid, parent_oid)
      end
    else
      new_oid = "#{self.class.oid_prefix}.#{id}"
      if self.class.where(oid: new_oid).count > 0
        new_oid = self.class.next_avail_oid(id)
      end
      update_attribute(:oid, new_oid)
    end
  end
def assign_oid if version > 1 parent_oid = self . class . where ( version_independent_id : version_independent_id , version : 1 ) . limit ( 1 ) . pluck ( :oid ) . first if parent_oid != oid && ! parent_oid . blank? update_attribute ( :oid , parent_oid ) end else new_oid = "#{self.class.oid_prefix}.#{id}" if self . class . where ( oid : new_oid ) . count > 0 new_oid = self . class . next_avail_oid ( id ) end update_attribute ( :oid , new_oid ) end end
Callback that assigns the oid.
Callback that assigns the oid .
# If not first version, set the oid to whatever the parent's oid was # If parent oid is blank, we get an infinite loop