triggerable 0.1.11 → 0.1.12

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: 7bc4c1f955221b2af177d36dacb12ce865450062
4
- data.tar.gz: 84169729da398ad1374641135e2174dea6483039
3
+ metadata.gz: 0ffbad6c797667eac50c61320135f018b185cc3f
4
+ data.tar.gz: 44f2d4c7b686d8919ed4192ec6ba9353f46fe31d
5
5
  SHA512:
6
- metadata.gz: 7dad2cfdd9d35e0778031c7f5634927e8ee763a17d6a11b4cb6cf69152e55652ca2b154b9b93e639eecbd73b462738bad3954d7cf259f280b6f0541398a5e7d5
7
- data.tar.gz: cbc5b85415d54ccf58574b3ddfac3adf636b0c829b7f1ade084c53e346c0f0649c4b7673cda39d2d1d0fc1f5da5615c3388cc7b196fb7fa5b5d58c205a2d85a6
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
@@ -1,3 +1,3 @@
1
1
  module Triggerable
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
  end
@@ -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.11
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