feature_switch 0.1.1 → 0.1.2
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.
- data/VERSION +1 -1
- data/lib/feature_switch.rb +4 -7
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/feature_switch.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
# @author Dan Williams
|
2
2
|
module FeatureSwitch
|
3
|
-
@@enabled_features = []
|
4
|
-
@@disabled_features = []
|
5
|
-
|
6
3
|
# Yields a block if the feature is enabled
|
7
4
|
#
|
8
5
|
# @param [Symbol] The feature to use as a guard-check
|
@@ -14,14 +11,14 @@ module FeatureSwitch
|
|
14
11
|
#
|
15
12
|
# @param [Symbol] The feature to enable
|
16
13
|
def enable(feature)
|
17
|
-
|
14
|
+
(@_enabled_features ||= []) << feature
|
18
15
|
end
|
19
16
|
|
20
17
|
# Disable a feature
|
21
18
|
#
|
22
19
|
# @param [Symbol] The feature to disable
|
23
20
|
def disable(feature)
|
24
|
-
|
21
|
+
(@_disabled_features ||= []) << feature
|
25
22
|
end
|
26
23
|
|
27
24
|
# Returns if the feature has been enabled
|
@@ -41,11 +38,11 @@ module FeatureSwitch
|
|
41
38
|
private
|
42
39
|
# Returns a list of enabled features
|
43
40
|
def enabled_features(user_services = [])
|
44
|
-
(user_services +
|
41
|
+
(user_services + (@_enabled_features ||= [])) - (@_disabled_features ||= [])
|
45
42
|
end
|
46
43
|
|
47
44
|
# Returns a list of disabled features
|
48
45
|
def disabled_features
|
49
|
-
|
46
|
+
(@_disabled_features ||= [])
|
50
47
|
end
|
51
48
|
end
|