HornsAndHooves-moribus 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moribus/tracked_behavior.rb +9 -2
- data/lib/moribus/version.rb +1 -1
- data/spec/moribus_spec.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f9194654bbeebef4db4c98f24246c8c444a307a
|
4
|
+
data.tar.gz: b21548da9a34e71cf86d81fc4f3223bccac26f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e010e70ad8cf22b9a909563faed39839e59dd6efb30bde31366502f31c75484ce1b7722e52945a8bb91aba842efd320ec59b28f68f3233d6a630b292cd8eb39
|
7
|
+
data.tar.gz: 0f3133f27b5a5896525ba3d2a7a8fcca56a25b65497fc949bdfb9579fc8248b74fd871f87c4c0f501a41f595916ebc95c1f3e2cb5b073a89110dc83241ac852a
|
@@ -59,7 +59,7 @@ module Moribus
|
|
59
59
|
affected_rows = self.class.connection.update statement
|
60
60
|
|
61
61
|
unless affected_rows == 1
|
62
|
-
raise ActiveRecord::StaleObjectError.new(self, "update_current")
|
62
|
+
raise ActiveRecord::StaleObjectError.new(self, "update_current (version #{current_lock_value})")
|
63
63
|
end
|
64
64
|
true
|
65
65
|
end
|
@@ -106,7 +106,7 @@ module Moribus
|
|
106
106
|
klass = self.class
|
107
107
|
is_current_col = klass.columns.detect { |c| c.name == "is_current" }
|
108
108
|
lock_column_name = klass.locking_column
|
109
|
-
lock_value =
|
109
|
+
lock_value = current_lock_value
|
110
110
|
lock_column = if lock_value
|
111
111
|
klass.columns.detect { |c| c.name == lock_column_name }
|
112
112
|
else
|
@@ -127,5 +127,12 @@ module Moribus
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
private :current_to_false_sql_statement
|
130
|
+
|
131
|
+
# Returns the current value of the locking column if such exists.
|
132
|
+
def current_lock_value
|
133
|
+
lock_column_name = self.class.locking_column
|
134
|
+
has_attribute?(lock_column_name) && read_attribute(lock_column_name).to_i
|
135
|
+
end
|
136
|
+
private :current_lock_value
|
130
137
|
end
|
131
138
|
end
|
data/lib/moribus/version.rb
CHANGED
data/spec/moribus_spec.rb
CHANGED
@@ -299,7 +299,8 @@ describe Moribus do
|
|
299
299
|
@info1.update_attributes(:spec_person_name_id => 3)
|
300
300
|
|
301
301
|
expect{ @info2.update_attributes(:spec_person_name_id => 4) }.
|
302
|
-
to raise_error(ActiveRecord::StaleObjectError
|
302
|
+
to raise_error(ActiveRecord::StaleObjectError,
|
303
|
+
"Attempted to update_current (version #{@info2.lock_version}) a stale object: SpecCustomerInfo")
|
303
304
|
end
|
304
305
|
|
305
306
|
it "updates lock_version incrementally for each new record" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HornsAndHooves-moribus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HornsAndHooves
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
version: '0'
|
208
208
|
requirements: []
|
209
209
|
rubyforge_project:
|
210
|
-
rubygems_version: 2.
|
210
|
+
rubygems_version: 2.6.8
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Introduces Aggregated and Tracked behavior to ActiveRecord::Base models
|