Liteguard Ruby SDK

Ruby SDK Gem Version

Installation

gem install liteguard

Or add to your Gemfile:

gem "liteguard"

Requires Ruby 3.1+.

Quick Start

require "liteguard"

client = Liteguard::Client.new(
  "pckid-...",
  environment: "production"
)
client.start

scope = client.create_scope(user_id: "user-123", plan: "pro")

if scope.open?("payments.checkout")
  # ...
end

client.shutdown

Primary API

  • Liteguard::Client.new(project_client_key_id, **options) creates a client.
  • client.start fetches the initial bundle and starts refresh and flush workers.
  • client.create_scope(**properties) creates an immutable scope.
  • scope.open?(name, **options) evaluates locally.
  • scope.execute_if_open(name, **options) { ... } measures guarded work.
  • scope.bind_protected_context(**protected_context) derives a protected scope.
  • client.flush flushes buffered telemetry.
  • client.shutdown flushes and stops background work.

Notes

  • Evaluation is local after the initial bundle fetch.
  • Prefer explicit client and scope usage.
  • Unadopted guards default open and emit no signals.

Development

make test-ruby

License

Apache 2.0 — see LICENSE.