flipper 0.6.3 → 0.7.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile +10 -10
- data/Guardfile +2 -1
- data/README.md +54 -23
- data/Rakefile +1 -1
- data/examples/dsl.rb +2 -2
- data/examples/{percentage_of_random.rb → percentage_of_time.rb} +1 -1
- data/lib/flipper.rb +25 -12
- data/lib/flipper/dsl.rb +96 -8
- data/lib/flipper/feature.rb +216 -37
- data/lib/flipper/gate.rb +6 -38
- data/lib/flipper/gate_values.rb +42 -0
- data/lib/flipper/gates/actor.rb +11 -13
- data/lib/flipper/gates/boolean.rb +3 -12
- data/lib/flipper/gates/group.rb +14 -16
- data/lib/flipper/gates/percentage_of_actors.rb +12 -13
- data/lib/flipper/gates/{percentage_of_random.rb → percentage_of_time.rb} +8 -11
- data/lib/flipper/instrumentation/log_subscriber.rb +1 -1
- data/lib/flipper/instrumentation/subscriber.rb +1 -1
- data/lib/flipper/spec/shared_adapter_specs.rb +16 -16
- data/lib/flipper/type.rb +1 -1
- data/lib/flipper/typecast.rb +44 -0
- data/lib/flipper/types/actor.rb +2 -5
- data/lib/flipper/types/group.rb +6 -0
- data/lib/flipper/types/percentage.rb +7 -1
- data/lib/flipper/types/{percentage_of_random.rb → percentage_of_time.rb} +1 -1
- data/lib/flipper/version.rb +1 -1
- data/script/bootstrap +21 -0
- data/script/guard +15 -0
- data/script/release +15 -0
- data/script/test +30 -0
- data/spec/flipper/dsl_spec.rb +67 -8
- data/spec/flipper/feature_spec.rb +424 -12
- data/spec/flipper/gate_spec.rb +1 -20
- data/spec/flipper/gate_values_spec.rb +134 -0
- data/spec/flipper/gates/actor_spec.rb +1 -21
- data/spec/flipper/gates/boolean_spec.rb +3 -71
- data/spec/flipper/gates/group_spec.rb +3 -23
- data/spec/flipper/gates/percentage_of_actors_spec.rb +5 -26
- data/spec/flipper/gates/percentage_of_time_spec.rb +23 -0
- data/spec/flipper/middleware/memoizer_spec.rb +1 -2
- data/spec/flipper/typecast_spec.rb +63 -0
- data/spec/flipper/types/group_spec.rb +21 -1
- data/spec/flipper/types/percentage_of_time_spec.rb +6 -0
- data/spec/flipper/types/percentage_spec.rb +20 -0
- data/spec/flipper_spec.rb +31 -9
- data/spec/helper.rb +1 -3
- data/spec/integration_spec.rb +22 -22
- metadata +21 -11
- data/spec/flipper/gates/percentage_of_random_spec.rb +0 -46
- data/spec/flipper/types/percentage_of_random_spec.rb +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 94132c1c49e833a166069931d26beee25f9f5a1e
|
|
4
|
+
data.tar.gz: 8575c2db458321be6d371f04b842e04f6a99daeb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51df2910a358380d4b1eace919c8f6277210cf4b007b1ab34c10376070041dc3ab843ab551d1d3524ac42599a1e3556bab53c3aaf890c2e81a24f40f7980ab26
|
|
7
|
+
data.tar.gz: bcce3fe6e79483dbc1eeae59b32743bdfef65cb711f532b9f4aa33752d74b5e31fef5ed39a76c6fb7be9fd3796ea4be23561cf1e1f5264d2f99c6da07779b444
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
2
|
gemspec
|
|
3
3
|
|
|
4
|
-
gem 'rake'
|
|
5
|
-
gem 'metriks', :require => false
|
|
6
|
-
gem 'statsd-ruby', :require => false
|
|
7
|
-
gem 'rspec'
|
|
8
|
-
gem 'rack-test'
|
|
9
|
-
gem 'activesupport', :require => false
|
|
4
|
+
gem 'rake', '~> 10.4.2'
|
|
5
|
+
gem 'metriks', '~> 0.9.9', :require => false
|
|
6
|
+
gem 'statsd-ruby', '~> 1.2.1', :require => false
|
|
7
|
+
gem 'rspec', '~> 2.14'
|
|
8
|
+
gem 'rack-test', '~> 0.6.3'
|
|
9
|
+
gem 'activesupport', '~> 4.2.0', :require => false
|
|
10
10
|
|
|
11
11
|
group(:guard) do
|
|
12
|
-
gem 'guard'
|
|
13
|
-
gem 'guard-rspec'
|
|
14
|
-
gem 'guard-bundler'
|
|
15
|
-
gem 'rb-fsevent'
|
|
12
|
+
gem 'guard', '~> 2.12.5'
|
|
13
|
+
gem 'guard-rspec', '~> 4.5.0'
|
|
14
|
+
gem 'guard-bundler', '~> 2.1.0'
|
|
15
|
+
gem 'rb-fsevent', '~> 0.9.4'
|
|
16
16
|
end
|
data/Guardfile
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
<pre>
|
|
4
|
-
__
|
|
4
|
+
__
|
|
5
5
|
_.-~ )
|
|
6
6
|
_..--~~~~,' ,-/ _
|
|
7
7
|
.-'. . . .' ,-',' ,' )
|
|
@@ -37,7 +37,7 @@ Or install it yourself with:
|
|
|
37
37
|
|
|
38
38
|
## Usage
|
|
39
39
|
|
|
40
|
-
The goal of the API for flipper was to have everything revolve around features and what ways they can be enabled. Start with top level and dig into a feature, then dig in further and enable that feature for a given type of access, as opposed to thinking about how the feature will be accessed first (ie: stats.enable vs activate_group(:stats, ...)).
|
|
40
|
+
The goal of the API for flipper was to have everything revolve around features and what ways they can be enabled. Start with top level and dig into a feature, then dig in further and enable that feature for a given type of access, as opposed to thinking about how the feature will be accessed first (ie: `stats.enable` vs `activate_group(:stats, ...)`).
|
|
41
41
|
|
|
42
42
|
```ruby
|
|
43
43
|
require 'flipper'
|
|
@@ -74,11 +74,11 @@ Of course there are more [examples for you to peruse](https://github.com/jnunema
|
|
|
74
74
|
|
|
75
75
|
## Types
|
|
76
76
|
|
|
77
|
-
Out of the box several types of enabling are supported. They are checked in this order
|
|
77
|
+
Out of the box several types of enabling are supported. They are checked in this order:
|
|
78
78
|
|
|
79
79
|
### 1. Boolean
|
|
80
80
|
|
|
81
|
-
All on or all off. Think top level things like
|
|
81
|
+
All on or all off. Think top level things like `:stats`, `:search`, `:logging`, etc. Also, an easy way to release a new feature as once a feature is boolean enabled it is on for every situation.
|
|
82
82
|
|
|
83
83
|
```ruby
|
|
84
84
|
flipper = Flipper.new(adapter)
|
|
@@ -97,13 +97,21 @@ Flipper.register(:admins) do |actor|
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
flipper = Flipper.new(adapter)
|
|
100
|
+
|
|
100
101
|
flipper[:stats].enable flipper.group(:admins) # turn on for admins
|
|
101
102
|
flipper[:stats].disable flipper.group(:admins) # turn off for admins
|
|
103
|
+
|
|
102
104
|
person = Person.find(params[:id])
|
|
103
105
|
flipper[:stats].enabled? person # check if enabled, returns true if person.admin? is true
|
|
106
|
+
|
|
107
|
+
# you can also use shortcut methods
|
|
108
|
+
flipper.enable_group :stats, :admins
|
|
109
|
+
flipper.disable_group :stats, :admins
|
|
110
|
+
flipper[:stats].enable_group :admins
|
|
111
|
+
flipper[:stats].disable_group :admins
|
|
104
112
|
```
|
|
105
113
|
|
|
106
|
-
There is no requirement that the thing yielded to the block be a user model or whatever. It can be anything you want therefore it is a good idea to check that the thing passed into the group block actually responds to what you are trying.
|
|
114
|
+
There is no requirement that the thing yielded to the block be a user model or whatever. It can be anything you want, therefore it is a good idea to check that the thing passed into the group block actually responds to what you are trying.
|
|
107
115
|
|
|
108
116
|
### 3. Individual Actor
|
|
109
117
|
|
|
@@ -121,11 +129,17 @@ flipper[:stats].enabled? user # false
|
|
|
121
129
|
# you can enable anything, does not need to be user or person
|
|
122
130
|
flipper[:search].enable group
|
|
123
131
|
flipper[:search].enabled? group
|
|
132
|
+
|
|
133
|
+
# you can also use shortcut methods
|
|
134
|
+
flipper.enable_actor :search, user
|
|
135
|
+
flipper.disable_actor :search, user
|
|
136
|
+
flipper[:search].enable_actor user
|
|
137
|
+
flipper[:search].disable_actor user
|
|
124
138
|
```
|
|
125
139
|
|
|
126
|
-
The key is to make sure you do not enable two different types of objects for the same feature. Imagine that user has a flipper_id of 6 and group has a flipper_id of 6. Enabling search for user would automatically enable it for group, as they both have a flipper_id of 6.
|
|
140
|
+
The key is to make sure you do not enable two different types of objects for the same feature. Imagine that user has a `flipper_id` of 6 and group has a `flipper_id` of 6. Enabling search for user would automatically enable it for group, as they both have a `flipper_id` of 6.
|
|
127
141
|
|
|
128
|
-
The one exception to this rule is if you have globally unique flipper_ids
|
|
142
|
+
The one exception to this rule is if you have globally unique `flipper_ids`, such as UUIDs. If your `flipper_ids` are unique globally in your entire system, enabling two different types should be safe. Another way around this is to prefix the `flipper_id` with the class name like this:
|
|
129
143
|
|
|
130
144
|
```ruby
|
|
131
145
|
class User
|
|
@@ -158,36 +172,47 @@ flipper[:stats].enable percentage
|
|
|
158
172
|
# user.flipper_id.to_s to ensure enabled distribution is smooth
|
|
159
173
|
flipper[:stats].enabled? user
|
|
160
174
|
|
|
175
|
+
# you can also use shortcut methods
|
|
176
|
+
flipper.enable_percentage_of_actors :search, 10
|
|
177
|
+
flipper.disable_percentage_of_actors :search # sets to 0
|
|
178
|
+
flipper[:search].enable_percentage_of_actors 10
|
|
179
|
+
flipper[:search].disable_percentage_of_actors # sets to 0
|
|
161
180
|
```
|
|
162
181
|
|
|
163
|
-
### 5. Percentage of
|
|
182
|
+
### 5. Percentage of Time
|
|
164
183
|
|
|
165
|
-
Turn this on for a
|
|
184
|
+
Turn this on for a percentage of time. Think load testing new features behind the scenes and such.
|
|
166
185
|
|
|
167
186
|
```ruby
|
|
168
187
|
flipper = Flipper.new(adapter)
|
|
169
188
|
|
|
170
|
-
# get percentage of
|
|
171
|
-
percentage = flipper.
|
|
189
|
+
# get percentage of time instance set to 5
|
|
190
|
+
percentage = flipper.time(5)
|
|
172
191
|
|
|
173
|
-
# turn on logging for 5 percent of the time
|
|
192
|
+
# turn on logging for 5 percent of the time
|
|
174
193
|
# could be on during one request and off the next
|
|
175
194
|
# could even be on first time in request and off second time
|
|
176
195
|
flipper[:logging].enable percentage
|
|
196
|
+
|
|
197
|
+
# you can also use shortcut methods
|
|
198
|
+
flipper.enable_percentage_of_time :search, 5
|
|
199
|
+
flipper.disable_percentage_of_time :search # sets to 0
|
|
200
|
+
flipper[:search].enable_percentage_of_time 5
|
|
201
|
+
flipper[:search].disable_percentage_of_time # sets to 0
|
|
177
202
|
```
|
|
178
203
|
|
|
179
|
-
|
|
204
|
+
Timeness is not a good idea for enabling new features in the UI. Most of the time you want a feature on or off for a user, but there are definitely times when I have found percentage of time to be very useful.
|
|
180
205
|
|
|
181
206
|
## Adapters
|
|
182
207
|
|
|
183
208
|
I plan on supporting [in-memory](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb), [Mongo](https://github.com/jnunemaker/flipper-mongo), and [Redis](https://github.com/jnunemaker/flipper-redis) as adapters for flipper. Others are welcome, so please let me know if you create one.
|
|
184
209
|
|
|
185
|
-
* [memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb)
|
|
186
|
-
* [
|
|
187
|
-
* [
|
|
188
|
-
* [
|
|
189
|
-
* [
|
|
190
|
-
* [
|
|
210
|
+
* [memory adapter](https://github.com/jnunemaker/flipper/blob/master/lib/flipper/adapters/memory.rb) – great for tests
|
|
211
|
+
* [Mongo adapter](https://github.com/jnunemaker/flipper-mongo)
|
|
212
|
+
* [Redis adapter](https://github.com/jnunemaker/flipper-redis)
|
|
213
|
+
* [Cassanity adapter](https://github.com/jnunemaker/flipper-cassanity)
|
|
214
|
+
* [Active Record 4 adapter](https://github.com/bgentry/flipper-activerecord)
|
|
215
|
+
* [Active Record 3 adapter](https://github.com/jproudman/flipper-activerecord)
|
|
191
216
|
|
|
192
217
|
The basic API for an adapter is this:
|
|
193
218
|
|
|
@@ -229,7 +254,7 @@ I would also recommend setting `fail_fast = true` in your RSpec configuration as
|
|
|
229
254
|
|
|
230
255
|
One optimization that flipper provides is a memoizing middleware. The memoizing middleware ensures that you only make one adapter call per feature per request.
|
|
231
256
|
|
|
232
|
-
This means if you check the same feature over and over, it will only make one
|
|
257
|
+
This means if you check the same feature over and over, it will only make one Mongo, Redis, or whatever call per feature for the length of the request.
|
|
233
258
|
|
|
234
259
|
You can use the middleware from a Rails initializer like so:
|
|
235
260
|
|
|
@@ -251,7 +276,7 @@ $flipper = Flipper.new(...)
|
|
|
251
276
|
config.middleware.use Flipper::Middleware::Memoizer, lambda { $flipper }
|
|
252
277
|
```
|
|
253
278
|
|
|
254
|
-
**Note**: Be sure that the
|
|
279
|
+
**Note**: Be sure that the middleware is high enough up in your stack that all feature checks are wrapped.
|
|
255
280
|
|
|
256
281
|
## Contributing
|
|
257
282
|
|
|
@@ -261,6 +286,12 @@ config.middleware.use Flipper::Middleware::Memoizer, lambda { $flipper }
|
|
|
261
286
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
262
287
|
5. Create new Pull Request
|
|
263
288
|
|
|
289
|
+
## Releasing
|
|
290
|
+
|
|
291
|
+
1. Update the version to be whatever it should be and commit.
|
|
292
|
+
2. `script/release`
|
|
293
|
+
3. Profit.
|
|
294
|
+
|
|
264
295
|
## Coming Soon™
|
|
265
296
|
|
|
266
|
-
* [Web UI](https://github.com/jnunemaker/flipper-ui) (think
|
|
297
|
+
* [Web UI](https://github.com/jnunemaker/flipper-ui) (think Resque UI for features toggling/status)
|
data/Rakefile
CHANGED
data/examples/dsl.rb
CHANGED
|
@@ -59,8 +59,8 @@ puts "stats.enabled?: #{stats.enabled?}"
|
|
|
59
59
|
puts "stats.enabled? person: #{stats.enabled? person}"
|
|
60
60
|
puts
|
|
61
61
|
|
|
62
|
-
# get an instance of the percentage of
|
|
63
|
-
puts flipper.
|
|
62
|
+
# get an instance of the percentage of time type set to 5
|
|
63
|
+
puts flipper.time(5).inspect
|
|
64
64
|
|
|
65
65
|
# get an instance of the percentage of actors type set to 15
|
|
66
66
|
puts flipper.actors(15).inspect
|
data/lib/flipper.rb
CHANGED
|
@@ -24,27 +24,39 @@ module Flipper
|
|
|
24
24
|
# Raises Flipper::DuplicateGroup if the group is already registered.
|
|
25
25
|
def self.register(name, &block)
|
|
26
26
|
group = Types::Group.new(name, &block)
|
|
27
|
-
|
|
27
|
+
groups_registry.add(group.name, group)
|
|
28
28
|
group
|
|
29
29
|
rescue Registry::DuplicateKey
|
|
30
|
-
raise DuplicateGroup,
|
|
30
|
+
raise DuplicateGroup, "Group #{name.inspect} has already been registered"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Public: Returns a Set of registered Types::Group instances.
|
|
34
|
+
def self.groups
|
|
35
|
+
groups_registry.values.to_set
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Public: Returns a Set of symbols where each symbol is a registered
|
|
39
|
+
# group name. If you just want the names, this is more efficient than doing
|
|
40
|
+
# `Flipper.groups.map(&:name)`.
|
|
41
|
+
def self.group_names
|
|
42
|
+
groups_registry.keys.to_set
|
|
31
43
|
end
|
|
32
44
|
|
|
33
45
|
# Public: Clears the group registry.
|
|
34
46
|
#
|
|
35
47
|
# Returns nothing.
|
|
36
48
|
def self.unregister_groups
|
|
37
|
-
|
|
49
|
+
groups_registry.clear
|
|
38
50
|
end
|
|
39
51
|
|
|
40
52
|
# Public: Check if a group exists
|
|
41
53
|
#
|
|
42
54
|
# Returns boolean
|
|
43
55
|
def self.group_exists?(name)
|
|
44
|
-
|
|
56
|
+
groups_registry.key?(name)
|
|
45
57
|
end
|
|
46
58
|
|
|
47
|
-
#
|
|
59
|
+
# Public: Fetches a group by name.
|
|
48
60
|
#
|
|
49
61
|
# name - The Symbol name of the group.
|
|
50
62
|
#
|
|
@@ -55,19 +67,19 @@ module Flipper
|
|
|
55
67
|
# Returns the Flipper::Group if group registered.
|
|
56
68
|
# Raises Flipper::GroupNotRegistered if group is not registered.
|
|
57
69
|
def self.group(name)
|
|
58
|
-
|
|
70
|
+
groups_registry.get(name)
|
|
59
71
|
rescue Flipper::Registry::KeyNotFound => e
|
|
60
72
|
raise GroupNotRegistered, "Group #{e.key.inspect} has not been registered"
|
|
61
73
|
end
|
|
62
74
|
|
|
63
|
-
# Internal: Registry of all
|
|
64
|
-
def self.
|
|
65
|
-
@
|
|
75
|
+
# Internal: Registry of all groups_registry.
|
|
76
|
+
def self.groups_registry
|
|
77
|
+
@groups_registry ||= Registry.new
|
|
66
78
|
end
|
|
67
79
|
|
|
68
|
-
# Internal: Change the
|
|
69
|
-
def self.
|
|
70
|
-
@
|
|
80
|
+
# Internal: Change the groups_registry registry.
|
|
81
|
+
def self.groups_registry=(registry)
|
|
82
|
+
@groups_registry = registry
|
|
71
83
|
end
|
|
72
84
|
end
|
|
73
85
|
|
|
@@ -78,3 +90,4 @@ require 'flipper/feature'
|
|
|
78
90
|
require 'flipper/gate'
|
|
79
91
|
require 'flipper/registry'
|
|
80
92
|
require 'flipper/type'
|
|
93
|
+
require 'flipper/typecast'
|
data/lib/flipper/dsl.rb
CHANGED
|
@@ -47,6 +47,50 @@ module Flipper
|
|
|
47
47
|
feature(name).enable(*args)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
# Public: Enable a feature for an actor.
|
|
51
|
+
#
|
|
52
|
+
# name - The String or Symbol name of the feature.
|
|
53
|
+
# actor - a Flipper::Types::Actor instance or an object that responds
|
|
54
|
+
# to flipper_id.
|
|
55
|
+
#
|
|
56
|
+
# Returns result of Feature#enable.
|
|
57
|
+
def enable_actor(name, actor)
|
|
58
|
+
feature(name).enable_actor(actor)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Public: Enable a feature for a group.
|
|
62
|
+
#
|
|
63
|
+
# name - The String or Symbol name of the feature.
|
|
64
|
+
# group - a Flipper::Types::Group instance or a String or Symbol name of a
|
|
65
|
+
# registered group.
|
|
66
|
+
#
|
|
67
|
+
# Returns result of Feature#enable.
|
|
68
|
+
def enable_group(name, group)
|
|
69
|
+
feature(name).enable_group(group)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Public: Enable a feature a percentage of time.
|
|
73
|
+
#
|
|
74
|
+
# name - The String or Symbol name of the feature.
|
|
75
|
+
# percentage - a Flipper::Types::PercentageOfTime instance or an object
|
|
76
|
+
# that responds to to_i.
|
|
77
|
+
#
|
|
78
|
+
# Returns result of Feature#enable.
|
|
79
|
+
def enable_percentage_of_time(name, percentage)
|
|
80
|
+
feature(name).enable_percentage_of_time(percentage)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Public: Enable a feature for a percentage of actors.
|
|
84
|
+
#
|
|
85
|
+
# name - The String or Symbol name of the feature.
|
|
86
|
+
# percentage - a Flipper::Types::PercentageOfActors instance or an object
|
|
87
|
+
# that responds to to_i.
|
|
88
|
+
#
|
|
89
|
+
# Returns result of Feature#enable.
|
|
90
|
+
def enable_percentage_of_actors(name, percentage)
|
|
91
|
+
feature(name).enable_percentage_of_actors(percentage)
|
|
92
|
+
end
|
|
93
|
+
|
|
50
94
|
# Public: Disable a feature.
|
|
51
95
|
#
|
|
52
96
|
# name - The String or Symbol name of the feature.
|
|
@@ -57,6 +101,50 @@ module Flipper
|
|
|
57
101
|
feature(name).disable(*args)
|
|
58
102
|
end
|
|
59
103
|
|
|
104
|
+
# Public: Disable a feature for an actor.
|
|
105
|
+
#
|
|
106
|
+
# name - The String or Symbol name of the feature.
|
|
107
|
+
# actor - a Flipper::Types::Actor instance or an object that responds
|
|
108
|
+
# to flipper_id.
|
|
109
|
+
#
|
|
110
|
+
# Returns result of disable.
|
|
111
|
+
def disable_actor(name, actor)
|
|
112
|
+
feature(name).disable_actor(actor)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Public: Disable a feature for a group.
|
|
116
|
+
#
|
|
117
|
+
# name - The String or Symbol name of the feature.
|
|
118
|
+
# group - a Flipper::Types::Group instance or a String or Symbol name of a
|
|
119
|
+
# registered group.
|
|
120
|
+
#
|
|
121
|
+
# Returns result of disable.
|
|
122
|
+
def disable_group(name, group)
|
|
123
|
+
feature(name).disable_group(group)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# Public: Disable a feature a percentage of time.
|
|
127
|
+
#
|
|
128
|
+
# name - The String or Symbol name of the feature.
|
|
129
|
+
# percentage - a Flipper::Types::PercentageOfTime instance or an object
|
|
130
|
+
# that responds to to_i.
|
|
131
|
+
#
|
|
132
|
+
# Returns result of disable.
|
|
133
|
+
def disable_percentage_of_time(name)
|
|
134
|
+
feature(name).disable_percentage_of_time
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Public: Disable a feature for a percentage of actors.
|
|
138
|
+
#
|
|
139
|
+
# name - The String or Symbol name of the feature.
|
|
140
|
+
# percentage - a Flipper::Types::PercentageOfActors instance or an object
|
|
141
|
+
# that responds to to_i.
|
|
142
|
+
#
|
|
143
|
+
# Returns result of disable.
|
|
144
|
+
def disable_percentage_of_actors(name)
|
|
145
|
+
feature(name).disable_percentage_of_actors
|
|
146
|
+
end
|
|
147
|
+
|
|
60
148
|
# Public: Access a feature instance by name.
|
|
61
149
|
#
|
|
62
150
|
# name - The String or Symbol name of the feature.
|
|
@@ -110,20 +198,20 @@ module Flipper
|
|
|
110
198
|
# thing - The object that you would like to wrap.
|
|
111
199
|
#
|
|
112
200
|
# Returns an instance of Flipper::Types::Actor.
|
|
113
|
-
# Raises ArgumentError if thing not
|
|
201
|
+
# Raises ArgumentError if thing does not respond to `flipper_id`.
|
|
114
202
|
def actor(thing)
|
|
115
203
|
Types::Actor.new(thing)
|
|
116
204
|
end
|
|
117
205
|
|
|
118
|
-
# Public: Shortcut for getting a percentage of
|
|
206
|
+
# Public: Shortcut for getting a percentage of time instance.
|
|
119
207
|
#
|
|
120
|
-
# number - The percentage of
|
|
208
|
+
# number - The percentage of time that should be enabled.
|
|
121
209
|
#
|
|
122
|
-
# Returns Flipper::Types::
|
|
123
|
-
def
|
|
124
|
-
Types::
|
|
210
|
+
# Returns Flipper::Types::PercentageOfTime.
|
|
211
|
+
def time(number)
|
|
212
|
+
Types::PercentageOfTime.new(number)
|
|
125
213
|
end
|
|
126
|
-
alias_method :
|
|
214
|
+
alias_method :percentage_of_time, :time
|
|
127
215
|
|
|
128
216
|
# Public: Shortcut for getting a percentage of actors instance.
|
|
129
217
|
#
|
|
@@ -135,7 +223,7 @@ module Flipper
|
|
|
135
223
|
end
|
|
136
224
|
alias_method :percentage_of_actors, :actors
|
|
137
225
|
|
|
138
|
-
#
|
|
226
|
+
# Public: Returns a Set of the known features for this adapter.
|
|
139
227
|
#
|
|
140
228
|
# Returns Set of Flipper::Feature instances.
|
|
141
229
|
def features
|