Module: Dcmgr::Models::UUIDMethods::ClassMethods

Included in:
Base
Defined in:
lib/dcmgr/models/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#prefix_uuidObject (readonly)

Returns the value of attribute prefix_uuid.



30
31
32
# File 'lib/dcmgr/models/base.rb', line 30

def prefix_uuid
  @prefix_uuid
end

Instance Method Details

#[](*args) ⇒ Object

override [] method. add search by uuid String



11
12
13
14
15
16
17
# File 'lib/dcmgr/models/base.rb', line 11

def [](*args)
  if args.size == 1 and args[0].is_a? String
    super(:uuid=>trim_uuid(args[0]))
  else
    super(*args)
  end
end

#set_prefix_uuid(prefix_uuid) ⇒ Object



26
27
28
# File 'lib/dcmgr/models/base.rb', line 26

def set_prefix_uuid(prefix_uuid)
  @prefix_uuid = prefix_uuid
end

#trim_uuid(p_uuid) ⇒ Object

Raises:



19
20
21
22
23
24
# File 'lib/dcmgr/models/base.rb', line 19

def trim_uuid(p_uuid)
  if p_uuid and p_uuid.length == self.prefix_uuid.length + 9
    return p_uuid[(self.prefix_uuid.length+1), p_uuid.length]
  end
  raise InvalidUUIDError, "invalid uuid: #{p_uuid}"
end