Home

Awesome

TypeID Ruby

A Ruby implementation of TypeIDs

Gem Version RubyDoc Main codecov License

TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.

This particular implementation provides a Ruby library for generating and parsing TypeIDs.

Installation

If using bundler

bundle add typeid

If not

gem install typeid

Usage

require "typeid"                        #=> true

id = TypeID.new("user")                 #=> #<TypeID user_01h46z1k2cf2av8mp4r7we4697>
id.to_s                                 #=> user_01h46z1k2cf2av8mp4r7we4697

other_id = TypeID.from_string(id.to_s)  #=> #<TypeID user_01h46z1k2cf2av8mp4r7we4697>
id == other_id                          #=> true

Attributions

This gem depends on uuid7 by sprql.