Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

36 lines (25 sloc) 0.957 kb
require './example_setup'
require 'flipper'
require 'flipper/adapters/memory'
adapter = Flipper::Adapters::Memory.new
flipper = Flipper.new(adapter)
stats = flipper[:stats]
# Some class that represents what will be trying to do something
class User
attr_reader :id
def initialize(id)
@id = id
end
end
pitt = User.new(1)
clooney = User.new(10)
puts "Stats for pitt: #{stats.enabled?(flipper.actor(pitt))}"
puts "Stats for clooney: #{stats.enabled?(flipper.actor(clooney))}"
puts "\nEnabling stats for 5 percent...\n\n"
stats.enable(Flipper::Types::PercentageOfActors.new(5))
puts "Stats for pitt: #{stats.enabled?(flipper.actor(pitt))}"
puts "Stats for clooney: #{stats.enabled?(flipper.actor(clooney))}"
puts "\nEnabling stats for 15 percent...\n\n"
stats.enable(Flipper::Types::PercentageOfActors.new(15))
puts "Stats for pitt: #{stats.enabled?(flipper.actor(pitt))}"
puts "Stats for clooney: #{stats.enabled?(flipper.actor(clooney))}"
Jump to Line
Something went wrong with that request. Please try again.