whenauser 0.6.1 → 0.6.2

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.
@@ -0,0 +1,29 @@
1
+ module ActiveRecord
2
+ module WhenAUserExtension
3
+ def save(*)
4
+ result = super
5
+ send_invalid_model_event if result == false
6
+ result
7
+ end
8
+
9
+ def save!(*)
10
+ begin
11
+ super
12
+ rescue ::ActiveRecord::RecordNotSaved
13
+ send_invalid_model_event
14
+ raise ::ActiveRecord::RecordNotSaved
15
+ end
16
+ end
17
+
18
+ private
19
+ def send_invalid_model_event
20
+ event = {
21
+ :_domain => 'invalid_model',
22
+ :_name => self.class.name,
23
+ :attributes => self.attributes,
24
+ :errors => self.errors.full_messages.to_sentence
25
+ }
26
+ WhenAUser.send_event event
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module WhenAUser
2
- VERSION = '0.6.1'
2
+ VERSION = '0.6.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whenauser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -72,6 +72,7 @@ files:
72
72
  - README.md
73
73
  - Rakefile
74
74
  - lib/whenauser.rb
75
+ - lib/whenauser/active_record_extension.rb
75
76
  - lib/whenauser/exceptions.rb
76
77
  - lib/whenauser/girl_friday_queue.rb
77
78
  - lib/whenauser/helpers.rb