mongoid_feature_flags 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -8,6 +8,8 @@ group :test do
8
8
  gem "guard-rspec"
9
9
  gem "guard-bundler"
10
10
  gem "mongoid"
11
+ gem "mongo"
12
+ gem "bson_ext"
11
13
  end
12
14
 
13
15
 
@@ -23,53 +23,51 @@ module Mongoid
23
23
  end
24
24
  end
25
25
 
26
- module InstanceMethods
27
- def add_feature(*flags)
28
- self.feature_flags ||= {}
29
- flags.each do |flag|
30
- self.feature_flags[flag] = true
31
- end
32
- self.save
33
- end
34
-
35
- def remove_feature(*flags)
36
- self.feature_flags ||= {}
37
- flags.each do |flag|
38
- self.feature_flags[flag] = false
39
- end
40
- self.save
26
+ def add_feature(*flags)
27
+ self.feature_flags ||= {}
28
+ flags.each do |flag|
29
+ self.feature_flags[flag] = true
41
30
  end
42
-
43
- def features
44
- inherited_feature_flags.merge(self.feature_flags)
45
- end
46
-
47
- def feature?(*required_features, &block)
48
- my_features = features
49
- if required_features.any? { |feature| my_features[feature] }
50
- block.present? ? block.yield : true
51
- end
31
+ self.save
32
+ end
33
+
34
+ def remove_feature(*flags)
35
+ self.feature_flags ||= {}
36
+ flags.each do |flag|
37
+ self.feature_flags[flag] = false
52
38
  end
53
-
54
- def not_feature?(*unrequired_features, &block)
55
- my_features = features
56
- if unrequired_features.none? { |feature| my_features[feature] }
57
- block.present? ? block.yield : true
58
- end
39
+ self.save
40
+ end
41
+
42
+ def features
43
+ inherited_feature_flags.merge(self.feature_flags)
44
+ end
45
+
46
+ def feature?(*required_features, &block)
47
+ my_features = features
48
+ if required_features.any? { |feature| my_features[feature] }
49
+ block.present? ? block.yield : true
59
50
  end
60
-
61
- def feature_flag_validate_flag(*flag)
62
- raise(InvalidFlagName, "Flags must be a symbol") if !flag.any? { |f| f.is_a?(Symbol) }
51
+ end
52
+
53
+ def not_feature?(*unrequired_features, &block)
54
+ my_features = features
55
+ if unrequired_features.none? { |feature| my_features[feature] }
56
+ block.present? ? block.yield : true
63
57
  end
58
+ end
59
+
60
+ def feature_flag_validate_flag(*flag)
61
+ raise(InvalidFlagName, "Flags must be a symbol") if !flag.any? { |f| f.is_a?(Symbol) }
62
+ end
64
63
 
65
- def inherited_feature_flags
66
- if self.class.instance_variable_defined?("@feature_flag_parents")
67
- self.class.instance_variable_get("@feature_flag_parents").inject({}) do |flag_hash, relative|
68
- if self.respond_to?(relative) && self.send(relative).present? && self.send(relative).respond_to?(:feature_flags)
69
- flag_hash.merge(self.send(relative).send(:feature_flags))
70
- else
71
- flag_hash
72
- end
64
+ def inherited_feature_flags
65
+ if self.class.instance_variable_defined?("@feature_flag_parents")
66
+ self.class.instance_variable_get("@feature_flag_parents").inject({}) do |flag_hash, relative|
67
+ if self.respond_to?(relative) && self.send(relative).present? && self.send(relative).respond_to?(:feature_flags)
68
+ flag_hash.merge(self.send(relative).send(:feature_flags))
69
+ else
70
+ flag_hash
73
71
  end
74
72
  end
75
73
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "mongo"
1
2
  require "mongoid"
2
3
 
3
4
  require_relative "../lib/mongoid_feature_flags"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid_feature_flags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: