Liteguard Ruby SDK
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.startfetches 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.flushflushes buffered telemetry.client.shutdownflushes 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.