Module: Uuids::Base::HasUuids
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/uuids/base/has_uuids.rb
Overview
Defines methods to be added by the has_uuids
class helper.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#uuid ⇒ String
Returns the first UUID (sorted as a string) for the record.
-
#uuid=(value) ⇒ Object
Assigns a new uuid to the record.
-
#uuids=(*values) ⇒ Object
Assigns a list of new uuids to the record.
Instance Method Details
#uuid ⇒ String
Returns the first UUID (sorted as a string) for the record.
42 43 44 |
# File 'lib/uuids/base/has_uuids.rb', line 42 def uuid uuids.map(&:value).sort.first end |
#uuid=(value) ⇒ Object
Assigns a new uuid to the record.
54 55 56 |
# File 'lib/uuids/base/has_uuids.rb', line 54 def uuid=(value) uuids.new value: value end |
#uuids=(*values) ⇒ Object
Assigns a list of new uuids to the record.
73 74 75 76 77 |
# File 'lib/uuids/base/has_uuids.rb', line 73 def uuids=(*values) first = values.first list = first.is_a?(Array) ? first : values list.each { |value| self.uuid = value } end |