Module: Attr::Gather::Concerns::Identifiable

Included in:
Workflow
Defined in:
lib/attr/gather/concerns/identifiable.rb

Overview

Makes an entity identifiable by adding a #uuid attribute

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#uuidString (readonly)

Returns UUID of the result.

Returns:

  • (String)

    UUID of the result



12
13
14
15
16
17
18
19
20
21
# File 'lib/attr/gather/concerns/identifiable.rb', line 12

module Identifiable
  def initialize(*)
    @uuid = SecureRandom.uuid
    super
  end

  def self.included(klass)
    klass.attr_reader(:uuid)
  end
end

Class Method Details

.included(klass) ⇒ Object



18
19
20
# File 'lib/attr/gather/concerns/identifiable.rb', line 18

def self.included(klass)
  klass.attr_reader(:uuid)
end

Instance Method Details

#initializeObject



13
14
15
16
# File 'lib/attr/gather/concerns/identifiable.rb', line 13

def initialize(*)
  @uuid = SecureRandom.uuid
  super
end