triggerable 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/triggerable.rb +1 -0
- data/lib/triggerable/conditions/field/not_in.rb +23 -0
- data/lib/triggerable/version.rb +1 -1
- data/spec/integration/conditions_spec.rb +16 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ffbad6c797667eac50c61320135f018b185cc3f
|
4
|
+
data.tar.gz: 44f2d4c7b686d8919ed4192ec6ba9353f46fe31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c71068450312d22d945a1ac3bd17c464faf9fc79972834ed555a550ab896e2725f264f00211b61280787c0424b5a5fadf3a34260eed3dee0263441c69cef7134
|
7
|
+
data.tar.gz: b48a47ab7a51487d1d8ad0b8d588277839ae3980929559c3eb36599e8c10a7274576dfd029103cc65a295b515b25f6ec0261d086fd3fd1a08b87c91630b3613d
|
data/lib/triggerable.rb
CHANGED
@@ -13,6 +13,7 @@ require "triggerable/conditions/method_condition"
|
|
13
13
|
require "triggerable/conditions/field/field_condition"
|
14
14
|
require "triggerable/conditions/field/exists"
|
15
15
|
require "triggerable/conditions/field/in"
|
16
|
+
require "triggerable/conditions/field/not_in"
|
16
17
|
require "triggerable/conditions/field/or_equal_to"
|
17
18
|
|
18
19
|
require "triggerable/conditions/predicate/predicate_condition"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Triggerable
|
2
|
+
module Conditions
|
3
|
+
class NotIn < FieldCondition
|
4
|
+
def initialize field, condition
|
5
|
+
super
|
6
|
+
@db_comparator = 'not in'
|
7
|
+
end
|
8
|
+
|
9
|
+
def true_for? object
|
10
|
+
!@value.include?(field_value(object))
|
11
|
+
end
|
12
|
+
|
13
|
+
def desc
|
14
|
+
"#{@field} #{@db_comparator} #{@value}"
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def sanitized_value
|
19
|
+
"(#{super.join(',')})"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/triggerable/version.rb
CHANGED
@@ -127,6 +127,22 @@ describe Triggerable::Conditions do
|
|
127
127
|
expect(TestTask.all.last.kind).to eq('follow up')
|
128
128
|
end
|
129
129
|
|
130
|
+
it 'not in' do
|
131
|
+
TestTask.trigger on: :after_update, if: { status: { not_in: ['solved', 'confirmed'] } } do
|
132
|
+
TestTask.create kind: 'follow up'
|
133
|
+
end
|
134
|
+
|
135
|
+
task = TestTask.create
|
136
|
+
expect(TestTask.count).to eq(1)
|
137
|
+
|
138
|
+
task.update_attributes status: 'solved'
|
139
|
+
expect(TestTask.count).to eq(1)
|
140
|
+
|
141
|
+
task.update_attributes status: 'open'
|
142
|
+
expect(TestTask.count).to eq(2)
|
143
|
+
expect(TestTask.all.last.kind).to eq('follow up')
|
144
|
+
end
|
145
|
+
|
130
146
|
it 'lambda' do
|
131
147
|
TestTask.trigger on: :after_update, if: -> {
|
132
148
|
status == 'solved' && kind == 'service'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triggerable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/triggerable/conditions/field/exists.rb
|
130
130
|
- lib/triggerable/conditions/field/field_condition.rb
|
131
131
|
- lib/triggerable/conditions/field/in.rb
|
132
|
+
- lib/triggerable/conditions/field/not_in.rb
|
132
133
|
- lib/triggerable/conditions/field/or_equal_to.rb
|
133
134
|
- lib/triggerable/conditions/lambda_condition.rb
|
134
135
|
- lib/triggerable/conditions/method_condition.rb
|