forked from flippercloud/flipper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
individual_actor.rb
32 lines (23 loc) · 709 Bytes
/
individual_actor.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require File.expand_path('../example_setup', __FILE__)
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
# Must respond to flipper_id
alias_method :flipper_id, :id
end
user1 = User.new(1)
user2 = User.new(2)
puts "Stats for user1: #{stats.enabled?(user1)}"
puts "Stats for user2: #{stats.enabled?(user2)}"
puts "\nEnabling stats for user1...\n\n"
stats.enable(user1)
puts "Stats for user1: #{stats.enabled?(user1)}"
puts "Stats for user2: #{stats.enabled?(user2)}"