Class: RightSupport::Data::UUID::Implementation

Inherits:
Object
  • Object
show all
Defined in:
lib/right_support/data/uuid.rb

Overview

The base class for all UUID implementations. Subclasses must override #initialize such that they raise an exception if the implementation is not available, and #generate such that it returns a String containing a UUID.

Direct Known Subclasses

SimpleUUID, UUIDGem, UUIDTools1, UUIDTools2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.availableObject

Determine which UUID implementations are available in this Ruby VM.

Return

available(Array)

the available implementation classes



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/right_support/data/uuid.rb', line 45

def self.available
  avail = []

  @subclasses.each do |eng|
    begin
      eng.new #if it initializes, it's available!
      avail << eng
    rescue Exception => e
      #must not be available!
    end
  end

  avail
end

.defaultObject

Determine the default UUID implementation in this Ruby VM.

Return

available(Array)

the available implementation classes



64
65
66
67
# File 'lib/right_support/data/uuid.rb', line 64

def self.default
  #completely arbitrary
  available.first
end

.inherited(klass) ⇒ Object



37
38
39
# File 'lib/right_support/data/uuid.rb', line 37

def self.inherited(klass)
  @subclasses << klass
end

Instance Method Details

#generateObject

Raises:



69
70
71
# File 'lib/right_support/data/uuid.rb', line 69

def generate
  raise Unavailable, "This implementation is currently not available"
end