Skip to content

Ruby SDK

feat-sdk (RubyGems) is the Ruby SDK. Standard library only, no gem dependencies. Evaluates flags locally against a polled datafile.

# Gemfile
gem "feat-sdk"
Terminal window
bundle install

Ruby 3.0 or newer.

require "feat"
client = Feat::Client.new(
api_key: ENV.fetch("FEAT_SERVER_KEY"),
data_plane_url: "https://data.feat.so",
)
client.start
ctx = {
targetingKey: "user-123",
user: { plan: "pro", email: "alice@example.com" },
}
if client.get_boolean_value("checkout-v2", false, ctx)
# ...
end
client.close

Use a server key (feat_sdk_…).

enabled = client.get_boolean_value("checkout-v2", false, ctx)
variant = client.get_string_value("hero-copy", "control", ctx)
limit = client.get_number_value("rate-limit", 100, ctx)
config = client.get_object_value("layout-config", {}, ctx)
result = client.evaluate("checkout-v2", false, ctx)
# result.value, result.variation_id, result.reason, result.error_message

reason is one of TARGETING_MATCH, SPLIT, FALLTHROUGH, DEFAULT, DISABLED, ERROR. See Evaluation order.

  • Feat::Client.new(...) constructs.
  • client.start spawns the polling thread. Call client.ready (or block on it implicitly via the first evaluation) before relying on values.
  • client.close stops the thread cleanly.
Feat::Client.new(
api_key: ENV.fetch("FEAT_SERVER_KEY"),
data_plane_url: "https://data.feat.so",
poll_interval: 30, # seconds; default 30, minimum 5
bootstrap: nil, # optional: a parsed datafile hash to skip the first fetch
)

The Ruby SDK ports the same evaluation algorithm as @feathq/feat-eval bit-for-bit. The same datafile, the same context, and the same flag key always give the same result across Node.js, Go, Python, and Ruby.