Skip to content

configcat/openfeature-ruby

Repository files navigation

ConfigCat OpenFeature Provider for Ruby

Build Status Gem Version

This repository contains an OpenFeature provider that allows ConfigCat to be used with the OpenFeature Ruby SDK.

Requirements

  • Ruby >= 3.1

Installation

gem install configcat-openfeature-provider

Usage

The initializer of ConfigCat::OpenFeature::Provider takes the SDK key and an optional ConfigCat::ConfigCatOptions argument containing the additional configuration options for the ConfigCat Ruby SDK:

require "configcat-openfeature-provider"

# Configure the OpenFeature API with the ConfigCat provider.
OpenFeature::SDK.configure do |config|
  config.set_provider(ConfigCat::OpenFeature::Provider.new(
    sdk_key: "<YOUR-CONFIGCAT-SDK-KEY>",
    # Build options for the ConfigCat SDK.
    options: ConfigCat::ConfigCatOptions.new(
      polling_mode: ConfigCat::PollingMode.auto_poll,
      offline: false
    )))
end

# Create a client.
client = OpenFeature::SDK.build_client

# Evaluate feature flag.
flag_value = client.fetch_boolean_value(
  flag_key: "isMyAwesomeFeatureEnabled",
  default_value: false
)

For more information about all the configuration options, see the Ruby SDK documentation.

Need help?

https://configcat.com/support

Contributing

Contributions are welcome. For more info please read the Contribution Guideline.

About ConfigCat

ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.

ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.