Ruby Quickstart

License validation for Ruby apps — Rails, Sinatra, or standalone gems.

5 minute setup
$ gem install traffic_orchestrator
1

Install the SDK

Add the Traffic Orchestrator gem to your project.

bash
# Bundler (Gemfile)
gem 'traffic_orchestrator'

# Or install directly
gem install traffic_orchestrator
2

Initialize the Client

Create a client instance in your Ruby application.

ruby
require 'traffic_orchestrator'

client = TrafficOrchestrator::Client.new(
  base_url: "https://api.trafficorchestrator.com/api/v1"
)
3

Validate a License Key

Verify a license key is valid and check which features it unlocks.

ruby
result = client.validate(
  key: "TO-XXXX-XXXX-XXXX",
  domain: "example.com"
)

if result.valid?
  puts "✅ License active!"
  puts "Features: #{result.features}"
else
  puts "❌ Invalid: #{result.error}"
end
4

Rails Integration

Add license checking to your Rails controllers with a before_action filter.

ruby
# app/controllers/concerns/license_check.rb
module LicenseCheck
  extend ActiveSupport::Concern

  included do
    before_action :verify_license
  end

  private

  def verify_license
    result = TO_CLIENT.validate(
      key: current_user.license_key,
      domain: request.host
    )

    unless result.valid?
      redirect_to upgrade_path,
        alert: "License required for this feature"
    end
  end
end