Module: NeoGruby::Sequel::Plugins::UuidPk

Defined in:
lib/neo_gruby/sequel/plugins/uuid_pk.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.parse_id(value, to_raw = false) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/neo_gruby/sequel/plugins/uuid_pk.rb', line 8

def parse_id(value, to_raw = false)
  value = UUIDTools::UUID.parse(value) if value.is_a?(String) && value.encoding.name != 'ASCII-8BIT'
  value = UUIDTools::UUID.parse_int(value) if value.is_a? Integer
  return(value.respond_to?(:raw) ? value.raw : value) if to_raw
  value = UUIDTools::UUID.parse_raw(value) unless value.nil?
  value
end