whenauser 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/whenauser/active_record_extension.rb +29 -0
- data/lib/whenauser/version.rb +1 -1
- metadata +2 -1
@@ -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
|
data/lib/whenauser/version.rb
CHANGED
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.
|
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
|