naranya_ecm-sdk 0.0.53 → 0.0.54

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
  SHA1:
3
- metadata.gz: 1ca18ddb2dee136305ec964bd7a4e21e85aca031
4
- data.tar.gz: cae662085784a09b9c704738d75440c7a70ab164
3
+ metadata.gz: 24ec59bfd778013ebd40fe4433c022e7e7f0ae26
4
+ data.tar.gz: f599005158ac669ab12fd0c5fc3dc29c024dcd41
5
5
  SHA512:
6
- metadata.gz: 46ac57df6f1d22a4fa44f925235422aa2b4cd3c45522f395e4fb8618fee235df56846ec57323b32b6e85ff8fc75821fb36f363fd1f452073142fcdeab93642a1
7
- data.tar.gz: 52458768d9951bad05c4d1aebf5ddeed03a1ec847c4521bc7f34f3a93381a4ff3d6079bd5e2da7bf3338afa449b98325c8f86de7f4b94dbe0af86fe8fd46c0b7
6
+ metadata.gz: 8f3440b7d4b6c2a2cfdc408bd31120c67079355d4986f7ab768a26aae56463075736fbcd620bcd7b33283a804fc371f73b167f13c4e95b50c6b73b882a545371
7
+ data.tar.gz: a19ac110a7f2c744c91debaed63d4664ccceeb86dd1c9e4f4f9d1863fa0918f73cbba318c46d8772b654bbb19a6372a38db0a64f2d78cc556680c2eeb94ec51d
@@ -114,19 +114,33 @@ module AASM
114
114
  end
115
115
 
116
116
  def aasm_fire_event(name, options, *args, &block)
117
- local_success = super
118
-
119
- if local_success
117
+ local_success = super
118
+ remote_success = if local_success
120
119
  data = { name: name, target_type: self.class.name.demodulize, target_id: self.id }
121
120
 
121
+ # byebug
122
+ unless NContent::SDK.config.state_event_delay < 1
123
+ NContent::SDK.logger.debug "Will wait #{NContent::SDK.config.state_event_delay} seconds before posting the event..."
124
+ sleep NContent::SDK.config.state_event_delay
125
+ end
126
+
122
127
  response = NContent::SDK::RESTClient.post "/events.json" do |req|
123
128
  req.headers[:content_type] = 'application/json'
124
129
  req.body = ActiveSupport::JSON.encode(state_event: data)
125
130
  end
126
131
 
127
- remote_success = response.status < 400
128
- unless remote_success
129
- end
132
+ state_attribute = self.class.aasm_column
133
+ state_before_reload = self.send(state_attribute)
134
+
135
+ reload
136
+ state_after_reload = self.send(state_attribute)
137
+
138
+ NContent::SDK.logger.debug "Event: #{name} - #{state_attribute} #{state_before_reload} -> #{state_after_reload}"
139
+
140
+ # Check that the state changed (and return the result of that check)
141
+ state_before_reload != state_after_reload
142
+ else
143
+ false
130
144
  end
131
145
 
132
146
  local_success && remote_success
@@ -1,3 +1,3 @@
1
1
  module NaranyaEcm
2
- VERSION = "0.0.53"
2
+ VERSION = "0.0.54"
3
3
  end
@@ -66,6 +66,10 @@ module NContent
66
66
 
67
67
  config_accessor(:notification_processing_modules) { [] }
68
68
 
69
+ config_accessor :state_event_delay do
70
+ (ENV.fetch 'NCONTENT_STATE_EVENT_DELAY', "1").to_i
71
+ end
72
+
69
73
  def new_relic_agent_available?
70
74
  defined?(::NewRelic) && defined?(::NewRelic::Agent)
71
75
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naranya_ecm-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.53
4
+ version: 0.0.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Quintanilla