ar_rollout 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85e6d7508732fb3709df78220d3b168d562f605a
4
+ data.tar.gz: b6a67b316ee04d76a7de82f75ecbe570c2c3f21e
5
+ SHA512:
6
+ metadata.gz: eeb84ff3f7c6e2e7a1b7608b12b3571ff5183b1e4bfa20cee75df4ff16d0f8dc077a2b2c2834f06086ae30bbae9e7319e7b823c7448ad243f4dc27725f197ee7
7
+ data.tar.gz: 91eda48dcdf8992338638409294b3fd5a8c4ecc7e5712601c42addd551a22aecfa2084d48f81c94d89c350a8f7f7527e110ddcd683e415dff9371d91992e523f
@@ -124,13 +124,7 @@ module ArRollout
124
124
 
125
125
  def self.all_active(user)
126
126
  return false unless user
127
- rollouts = []
128
- Rollout.where("user_id = ? or user_id is NULL", user.id).each do |rollout|
129
- unless OptOut.where(feature: rollout.name, user_id: user.id).any?
130
- rollouts << rollout.name if rollout.match?(user)
131
- end
132
- end
133
- rollouts.uniq.sort
127
+ Rollout.matching(user).collect(&:name).sort
134
128
  end
135
129
 
136
130
  private
@@ -3,6 +3,13 @@ class Rollout < ActiveRecord::Base
3
3
  validates :name, presence: true
4
4
  validate :validate_one_rollout
5
5
 
6
+ def self.matching(user)
7
+ where('"rollouts".user_id = ? OR "rollouts".user_id IS NULL', user.id).
8
+ where('"rollouts".name NOT IN (SELECT feature FROM "opt_outs" WHERE "opt_outs".user_id = ?)', user.id).uniq_by(&:name).select do |rollout|
9
+ rollout.match? user
10
+ end
11
+ end
12
+
6
13
  def match?(user)
7
14
  return false unless user
8
15
  enabled? && (match_user?(user) || match_group?(user) || match_percentage?(user))
@@ -1,3 +1,3 @@
1
1
  module ArRollout
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.22"
3
3
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar_rollout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
5
- prerelease:
4
+ version: 0.0.22
6
5
  platform: ruby
7
6
  authors:
8
7
  - Enrico Carlesso
@@ -13,12 +12,11 @@ authors:
13
12
  autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
- date: 2012-12-07 00:00:00.000000000 Z
15
+ date: 2013-05-23 00:00:00.000000000 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
18
  name: rails
20
19
  requirement: !ruby/object:Gem::Requirement
21
- none: false
22
20
  requirements:
23
21
  - - ~>
24
22
  - !ruby/object:Gem::Version
@@ -26,7 +24,6 @@ dependencies:
26
24
  type: :runtime
27
25
  prerelease: false
28
26
  version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
27
  requirements:
31
28
  - - ~>
32
29
  - !ruby/object:Gem::Version
@@ -34,49 +31,43 @@ dependencies:
34
31
  - !ruby/object:Gem::Dependency
35
32
  name: sqlite3
36
33
  requirement: !ruby/object:Gem::Requirement
37
- none: false
38
34
  requirements:
39
- - - ! '>='
35
+ - - '>='
40
36
  - !ruby/object:Gem::Version
41
37
  version: '0'
42
38
  type: :development
43
39
  prerelease: false
44
40
  version_requirements: !ruby/object:Gem::Requirement
45
- none: false
46
41
  requirements:
47
- - - ! '>='
42
+ - - '>='
48
43
  - !ruby/object:Gem::Version
49
44
  version: '0'
50
45
  - !ruby/object:Gem::Dependency
51
46
  name: rspec
52
47
  requirement: !ruby/object:Gem::Requirement
53
- none: false
54
48
  requirements:
55
- - - ! '>='
49
+ - - '>='
56
50
  - !ruby/object:Gem::Version
57
51
  version: '0'
58
52
  type: :development
59
53
  prerelease: false
60
54
  version_requirements: !ruby/object:Gem::Requirement
61
- none: false
62
55
  requirements:
63
- - - ! '>='
56
+ - - '>='
64
57
  - !ruby/object:Gem::Version
65
58
  version: '0'
66
59
  - !ruby/object:Gem::Dependency
67
60
  name: bcrypt-ruby
68
61
  requirement: !ruby/object:Gem::Requirement
69
- none: false
70
62
  requirements:
71
- - - ! '>='
63
+ - - '>='
72
64
  - !ruby/object:Gem::Version
73
65
  version: '0'
74
66
  type: :development
75
67
  prerelease: false
76
68
  version_requirements: !ruby/object:Gem::Requirement
77
- none: false
78
69
  requirements:
79
- - - ! '>='
70
+ - - '>='
80
71
  - !ruby/object:Gem::Version
81
72
  version: '0'
82
73
  description: ''
@@ -104,26 +95,25 @@ files:
104
95
  - README.md
105
96
  homepage: https://github.com/markpundsack/ar_rollout
106
97
  licenses: []
98
+ metadata: {}
107
99
  post_install_message:
108
100
  rdoc_options: []
109
101
  require_paths:
110
102
  - lib
111
103
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
104
  requirements:
114
- - - ! '>='
105
+ - - '>='
115
106
  - !ruby/object:Gem::Version
116
107
  version: '0'
117
108
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
109
  requirements:
120
- - - ! '>='
110
+ - - '>='
121
111
  - !ruby/object:Gem::Version
122
112
  version: '0'
123
113
  requirements: []
124
114
  rubyforge_project:
125
- rubygems_version: 1.8.24
115
+ rubygems_version: 2.0.3
126
116
  signing_key:
127
- specification_version: 3
117
+ specification_version: 4
128
118
  summary: An ActiveRecord version of Rollout gem (https://github.com/jamesgolick/rollout).
129
119
  test_files: []