Module: Mongoid::Uuid

Extended by:
ActiveSupport::Concern
Includes:
Uuid
Defined in:
lib/mongoid/uuid/uuid.rb,
lib/mongoid/uuid.rb,
lib/mongoid/uuid/version.rb,
lib/mongoid/uuid/validator.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Uuid, Validator

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.validate(uuid) ⇒ Object



12
13
14
15
16
# File 'lib/mongoid/uuid.rb', line 12

def self.validate(uuid)
  uuid.class.to_s == 'BSON::Binary' and
    uuid.type == :uuid and
    validate_format(uuid.data)
end

.validate_format(uuid) ⇒ Object



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

def self.validate_format(uuid)
  return true if uuid =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i
end