Class: UUIDTools::UUID

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.serialize(value) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/activeuuid/uuid.rb', line 32

def self.serialize(value)
  case value
  when self
    value
  when String
    parse_string value
  end
end

Instance Method Details

#==(another_uuid) ⇒ Object



11
12
13
# File 'lib/activeuuid/uuid.rb', line 11

def ==(another_uuid)
  to_s == another_uuid.to_s
end

#as_json(_options = nil) ⇒ Object



24
25
26
# File 'lib/activeuuid/uuid.rb', line 24

def as_json(_options = nil)
  to_s
end

#bytesizeObject



41
42
43
# File 'lib/activeuuid/uuid.rb', line 41

def bytesize
  16
end

#gsubObject

duck typing activerecord 3.1 dirty hack )



9
# File 'lib/activeuuid/uuid.rb', line 9

def gsub(*); self; end

#nextObject



15
16
17
# File 'lib/activeuuid/uuid.rb', line 15

def next
  self.class.random_create
end

#quoted_idObject



19
20
21
22
# File 'lib/activeuuid/uuid.rb', line 19

def quoted_id
  s = raw.unpack("H*")[0]
  "x'#{s}'"
end

#to_paramObject



28
29
30
# File 'lib/activeuuid/uuid.rb', line 28

def to_param
  to_s
end