feature_gate 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3119c0371d52b6fbacd61632f253699d66a446be
4
- data.tar.gz: 6eb1f8f6cccc66078107a1a34d3e474a78757dfc
3
+ metadata.gz: 6185eca27fa85dcd189393c552a18406692e6b29
4
+ data.tar.gz: f781afb28fedc00e244aa27942634efdcff84072
5
5
  SHA512:
6
- metadata.gz: e1578a389e2f41258a4889f6c82d9b775c410626f7e6cd42c521c71e6fea6317f1ea3ed7aa83f03c36d6baa4a2f7822f1bd75956fbdf67fbf741a1453eeb91f2
7
- data.tar.gz: 62e7c216ea601137b17aa76be5948f662496c7f25ca73a2583295129f774469056faa83293b9cffbcff8560a82a2c0851ed063bea6424633d7ac03044e11638c
6
+ metadata.gz: c2a2f446101714d40edc315736e9ac659fa00f8af885e12f6c79dc040911f26aa96fd505277e9530bc5def0bfd876c67c5605570aaec990c5fe470b4970e2051
7
+ data.tar.gz: 8dd76bd9844de3280bd086ae1947b4f54d03384ff8c0ddd127b120afa9c12720dd14c13fab1f748d36a71540b43468c40b956e0646264708ae968287ade7a653
@@ -1,4 +1,14 @@
1
1
  class GatedFeature < ActiveRecord::Base
2
2
  validates :name, presence: true
3
3
  validates :gated, inclusion: { in: [true, false] }
4
+
5
+ def turn_on!
6
+ self.gated = false
7
+ save!
8
+ end
9
+
10
+ def turn_off!
11
+ self.gated = true
12
+ save!
13
+ end
4
14
  end
data/lib/feature_gate.rb CHANGED
@@ -10,12 +10,29 @@ module FeatureGate
10
10
  yield self
11
11
  end
12
12
 
13
+ def self.gate_page(name)
14
+ gated_feature = GatedFeature.where(name: name).first_or_create
15
+ if gated_feature.gated?
16
+ raise ActiveRecord::RecordNotFound
17
+ end
18
+ end
19
+
13
20
  def self.gate(name)
14
21
  gated_feature = GatedFeature.where(name: name).first_or_create
15
22
  if !gated_feature.gated?
16
23
  yield
17
24
  end
18
25
  end
26
+
27
+ def self.turn_on!(name)
28
+ gated_feature = GatedFeature.find_by_name!(name)
29
+ gated_feature.turn_on!
30
+ end
31
+
32
+ def self.turn_off!(name)
33
+ gated_feature = GatedFeature.find_by_name!(name)
34
+ gated_feature.turn_on!
35
+ end
19
36
  end
20
37
 
21
38
  require 'feature_gate/engine'
@@ -1,3 +1,3 @@
1
1
  module FeatureGate
2
- VERSION = '0.0.5'.freeze
2
+ VERSION = '0.0.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature_gate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiffany Huang