Ruby SDK
Rubyv0.1.2
Terminal window
Terminal window
Installation
Section titled “Installation”Add to your Gemfile:
gem 'flags-gem'Then run:
bundle installOr install directly:
gem install flags-gemQuick Start
Section titled “Quick Start”require 'flags'
client = Flags::Client.builder .with_auth(Flags::Auth.new( project_id: 'your-project-id', agent_id: 'your-agent-id', environment_id: 'your-environment-id' )) .with_memory_cache .build
# Check a flagif client.is('my-feature').enabled? puts 'Feature is enabled!'end
# List all flagsflags = client.listflags.each do |flag| puts "#{flag.details.name}: #{flag.enabled}"endError Handling
Section titled “Error Handling”begin client.is('my-flag').enabled?rescue Flags::AuthError => e puts "Authentication error: #{e.message}"rescue Flags::ApiError => e puts "API error: #{e.message}"rescue Flags::HttpError => e puts "HTTP error: #{e.message}"rescue Flags::CacheError => e puts "Cache error: #{e.message}"end