feature_flags 0.0.2 → 0.0.3
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/README.md +4 -7
- data/lib/feature_flags.rb +1 -26
- data/lib/feature_flags/manage_features.rb +56 -0
- data/lib/feature_flags/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -31,22 +31,19 @@ then do
|
|
31
31
|
|
32
32
|
rake db:migrate
|
33
33
|
|
34
|
-
##############################################################################
|
35
|
-
|
36
|
-
To check whether paritcular feature is enabled or not use
|
37
|
-
|
38
|
-
FeatureFlags.enabled?(:feature_name)
|
39
|
-
|
40
|
-
this will check whether feature is enabled or not, and if its not present/created ,it will create that feature and set it to enabled by default.
|
41
34
|
|
42
35
|
##############################################################################
|
36
|
+
FeatureFlags.enabled?(:feature_name) To check whether particular feature is enabled or not
|
43
37
|
|
44
38
|
FeatureFlags.enable_all To enable all features in your app.
|
45
39
|
|
46
40
|
FeatureFlags.disable_all To disable all features in your app.
|
47
41
|
|
48
42
|
FeatureFlags.set_disabled(:feature_name) To disable feature in your app.
|
43
|
+
|
44
|
+
FeatureFlags.create_and_enable(:feature_name) To create and enable feature
|
49
45
|
|
46
|
+
FeatureFlags.enable(feature_name) To enable feature
|
50
47
|
|
51
48
|
##############################################################################
|
52
49
|
|
data/lib/feature_flags.rb
CHANGED
@@ -1,35 +1,10 @@
|
|
1
1
|
|
2
2
|
require "feature_flags/version"
|
3
3
|
require "feature_flags/configuration"
|
4
|
+
require "feature_flags/manage_features"
|
4
5
|
require "feature_flags/engine"
|
5
6
|
require "active_support/dependencies"
|
6
7
|
|
7
8
|
module FeatureFlags
|
8
9
|
# Your code goes here...\
|
9
|
-
|
10
|
-
def self.enabled?(feature_name)
|
11
|
-
feature = Feature.where(:name => feature_name).first
|
12
|
-
|
13
|
-
if feature.present?
|
14
|
-
feature.status? ? true : false
|
15
|
-
elsif
|
16
|
-
Feature.create!(:name => feature_name, :status => true)
|
17
|
-
return true
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.set_disabled(feature_name)
|
23
|
-
feature = Feature.where(:name => feature_name).first
|
24
|
-
(feature.present? && feature.update_attributes(:status => false)) ? true : false
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.disable_all
|
28
|
-
Feature.update_all(:status => false)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.enable_all
|
32
|
-
Feature.update_all(:status => true)
|
33
|
-
end
|
34
|
-
|
35
10
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module FeatureFlags
|
2
|
+
def self.enabled?(feature_name)
|
3
|
+
feature = Feature.where(:name => feature_name).last
|
4
|
+
|
5
|
+
if feature.present?
|
6
|
+
feature.status? ? true : false
|
7
|
+
else
|
8
|
+
#Feature.create!(:name => feature_name, :status => true)
|
9
|
+
#return true
|
10
|
+
raise "#{feature_name} feature not found."
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create_and_enable(feature_name)
|
16
|
+
feature = Feature.new(:name => feature_name, :status => true)
|
17
|
+
feature.save ? true : false
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.enable(feature_name)
|
21
|
+
feature = Feature.where(:name => feature_name).last
|
22
|
+
if feature.present?
|
23
|
+
|
24
|
+
if feature.update_attributes(:status => true)
|
25
|
+
return true
|
26
|
+
else
|
27
|
+
false
|
28
|
+
end
|
29
|
+
else
|
30
|
+
raise "#{feature_name} feature not found."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.set_disabled(feature_name)
|
35
|
+
feature = Feature.where(:name => feature_name).last
|
36
|
+
if feature.present?
|
37
|
+
|
38
|
+
if feature.update_attributes(:status => false)
|
39
|
+
return true
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
43
|
+
else
|
44
|
+
raise "#{feature_name} feature not found."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.disable_all
|
49
|
+
Feature.update_all(:status => false)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.enable_all
|
53
|
+
Feature.update_all(:status => true)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/feature_flags.rb
|
66
66
|
- lib/feature_flags/configuration.rb
|
67
67
|
- lib/feature_flags/engine.rb
|
68
|
+
- lib/feature_flags/manage_features.rb
|
68
69
|
- lib/feature_flags/version.rb
|
69
70
|
- lib/generators/feature_flags/install_generator.rb
|
70
71
|
- lib/generators/feature_flags/templates/feature_flag.rb
|