feature_gate 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/app/controllers/feature_gate/gated_features_controller.rb +12 -0
- data/lib/feature_gate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0406848d929e8aa0f675c4814a10c36f6663a0a
|
4
|
+
data.tar.gz: 7e46b5a0e1997b71a45fb71effe93c0a4777ab68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c65230e8cc3f0e3fd7ab7461da9d602d6e77131c08fd233bc01d60c7a72f797bd64c1c72eb7b5babff0d8a57755a337936e23ffc85017241fc70f3b356cf3eba
|
7
|
+
data.tar.gz: 8a2a00751a311f9c289511601957f049defdb5a9df44a85b543eec50af442d436c1e01ef76d6903110fb2af64a39022f13d5331d591d9a79dd787f38e79bf3f1
|
data/README.md
CHANGED
@@ -22,6 +22,8 @@ Add to `config/routes.rb`
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
+
### Gating features
|
26
|
+
|
25
27
|
All gates are closed by default, meaning the features you gate will be hidden until you toggle the gates open.
|
26
28
|
|
27
29
|
In view files:
|
@@ -37,6 +39,22 @@ In controller actions:
|
|
37
39
|
FeatureGate::Manager.gate_page('gate-name') # 404s if gate is closed
|
38
40
|
end
|
39
41
|
|
42
|
+
### Managing gates
|
43
|
+
|
44
|
+
#### Option 1: UI interface
|
45
|
+
|
46
|
+
<img src="http://i.imgur.com/aeRlKv0.png" border="1">
|
47
|
+
|
48
|
+
Go to `/feature_gate` for a preconfigured page that lists all your gates and give you the ability to toggle them open or close.
|
49
|
+
|
50
|
+
To limit accessibility to this page, define `feature_gate_control_allowed?` in `application_controller.rb`. If the method is not defined, `/feature_gate` will be accessible to <em>all</em> users.
|
51
|
+
|
52
|
+
def feature_gate_control_allowed?
|
53
|
+
# condition for allowing user to toggle feature gates, ex: current_admin_user.present?
|
54
|
+
end
|
55
|
+
|
56
|
+
#### Option 2: Console
|
57
|
+
|
40
58
|
To deploy your feature:
|
41
59
|
|
42
60
|
FeatureGate::Manager.open!('gate-name')
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module FeatureGate
|
2
2
|
class GatedFeaturesController < ApplicationController
|
3
|
+
before_filter :ensure_feature_gate_control_allowed
|
3
4
|
layout 'feature_gate/application'
|
4
5
|
|
5
6
|
def index
|
@@ -19,5 +20,16 @@ module FeatureGate
|
|
19
20
|
|
20
21
|
redirect_to gated_features_path
|
21
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
define_method(:feature_gate_control_allowed?) do
|
27
|
+
true
|
28
|
+
end unless method_defined? :feature_gate_control_allowed?
|
29
|
+
|
30
|
+
def ensure_feature_gate_control_allowed
|
31
|
+
return if feature_gate_control_allowed?
|
32
|
+
raise ActionController::RoutingError.new('Not Found')
|
33
|
+
end
|
22
34
|
end
|
23
35
|
end
|
data/lib/feature_gate/version.rb
CHANGED