icalia-sdk-event-notification 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a963ff044e4f2d80cf7a11621fc68d69d8a6173fde87e4c4eba61391a7c325fa
4
- data.tar.gz: 290e6b1d01049f54ae0d5db082423249b5240166578351aff68645e947ce5451
3
+ metadata.gz: 8f0ee4cf2738f37b32ac9cb2154b166963ce2ce7ef1e1b50e94dd535fc9c1ef1
4
+ data.tar.gz: 17bf2ac51dfcbcaaaf2fb98e44cd4fd0011b95c67e62f7decf6f7a9537647a83
5
5
  SHA512:
6
- metadata.gz: d2a082516d338bca8a304a9b0b63f36157f116874e7750189544ff8b3e7b8c10e2517a01cd6095c02eb90d4f1d17b82dfd2981aae4ab28fcfc494ca5d1a29861
7
- data.tar.gz: 0b486edace31a5cfaa2f883166e2124487b31e04e8df0f330142dee2a417a0843e9641ce8822834bb60ddc09079be79c6399468e435a529787ab14d34d414303
6
+ metadata.gz: 9d7c9ef8d63f0ccaa6e3f6708ee02276848aec043e6630610f0f715650e71622faa20cb24077f937752282181889c05050ea0339aa83d6a77ad63f55ee9d979e
7
+ data.tar.gz: b599aa5e0d38d0e6583c659de6dfe9588447e359e29a4b8128ee018ed531fa04fbbf648eaecd3d0001113eeca64a88d63ebc826156f23dc163688a4e3fa0974a
@@ -13,6 +13,7 @@ module Icalia::Event
13
13
 
14
14
  included do
15
15
  mattr_reader :delayed_icalia_event_publishing, default: true
16
+ mattr_reader :icalia_event_publishing_enabled, default: true
16
17
 
17
18
  after_commit :publish_create_to_icalia_events, on: :create
18
19
  after_commit :publish_update_to_icalia_events, on: :update
@@ -22,6 +23,7 @@ module Icalia::Event
22
23
  :icalia_event_publisher_class,
23
24
  :icalia_events_publisher_method,
24
25
  :delayed_icalia_event_publishing?,
26
+ :icalia_event_publishing_enabled?,
25
27
  to: :class
26
28
  end
27
29
 
@@ -44,10 +46,7 @@ module Icalia::Event
44
46
  end
45
47
 
46
48
  def icalia_event_publishing_enabled?
47
- :publish_to_icalia_events.in? self
48
- ._commit_callbacks
49
- .select { |callback| callback.kind.eql?(:after) }
50
- .map(&:filter)
49
+ icalia_event_publishing_enabled == true
51
50
  end
52
51
 
53
52
  def icalia_event_publishing_disabled?
@@ -55,11 +54,11 @@ module Icalia::Event
55
54
  end
56
55
 
57
56
  def disable_icalia_event_publishing
58
- skip_callback(:commit, :after, :publish_to_icalia_events)
57
+ class_variable_set :@@icalia_event_publishing_enabled, false
59
58
  end
60
59
 
61
60
  def enable_icalia_event_publishing
62
- set_callback(:commit, :after, :publish_to_icalia_events)
61
+ class_variable_set :@@icalia_event_publishing_enabled, true
63
62
  end
64
63
 
65
64
  def without_icalia_event_publishing(&_block)
@@ -67,6 +66,8 @@ module Icalia::Event
67
66
  result = yield self
68
67
  enable_icalia_event_publishing if icalia_event_publishing_disabled?
69
68
  result
69
+ ensure
70
+ enable_icalia_event_publishing if icalia_event_publishing_disabled?
70
71
  end
71
72
 
72
73
  def icalia_event_class_name
@@ -86,6 +87,7 @@ module Icalia::Event
86
87
  private
87
88
 
88
89
  def publish_to_icalia_events(action)
90
+ return unless icalia_event_publishing_enabled?
89
91
  publisher_class = icalia_event_publisher_class
90
92
  return unless publisher_class.present?
91
93
  publisher_class.send icalia_events_publisher_method, action.to_s, self
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Icalia
4
4
  module Event
5
- NOTIFICATION_VERSION = '0.1.8'
5
+ NOTIFICATION_VERSION = '0.1.9'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icalia-sdk-event-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Quintanilla
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.8
19
+ version: 0.1.9
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.8
26
+ version: 0.1.9
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement