Class: Uuids::Models::Uuid

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/uuid.rb

Overview

The model describes uuids assigned to corresponding records. article.

Examples:

# Creates the uuid
uuid = Uuids::Models::Uuid.create! record: some_record

# Finds a record by uuid
Uuid.find_by_value(uuid.value).record # => some_record

# Reassigns a uuid to another record
uuid.update_attributes! record: another_record

See Also:

Constant Summary collapse

UUID =

Assigned by default on creation. Cannot be set or edited manually.

Returns:

  • (String)

    uuid value as defined in RFC4122.

/[a-z\d]{8}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{12}/

Instance Attribute Summary collapse

Instance Attribute Details

#recordActiveRecord::Base

Returns an object the uuid is assigned to.

Returns:

  • (ActiveRecord::Base)

    an object the uuid is assigned to.



37
# File 'app/models/uuid.rb', line 37

belongs_to :record, polymorphic: true

#valueString (readonly)

Assigned by default on creation. Cannot be set or edited manually.

Returns:

  • (String)

    uuid value as defined in RFC4122.



30
# File 'app/models/uuid.rb', line 30

UUID = /[a-z\d]{8}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{12}/