Ruby
Our API Reference has generic examples in every supported language, and we strive to make the experience of each SDK very similar. However, there are some things specific to the Ruby SDK that we want to call out here.
Types
We provide types for both our Ruby SDK and generated Ruby code in both RBS and Sorbet flavors.
Key Path Helpers
The StatelyDB::KeyPath
class can be used to safely construct key paths:
This will produce a key path like /movie-p05olqcFSfC6zOqEojxT9g
, correctly encoding a UUID ID. You can append more segments onto an existing KeyPath using with
:
Checking an Item’s Type
Many client APIs return a list of items, but you want to know exactly what type each item is.
UUIDs
UUIDs use the StatelyDB::UUID
type, which can be constructed from a standard 36-byte UUID string using StatelyDB::UUID.parse(input)
. to_s
produces that output, while to_base64
produces the Stately base64 version.
Enums
Enums are generated as modules under StatelyDB::Types::Enum
. Each enum module has a constant for each value, plus a from_int
class method that can be used to validate that a value exists in the enum.