HornsAndHooves-moribus 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +1 -1
- data/lib/moribus/alias_association.rb +1 -1
- data/lib/moribus/tracked_behavior.rb +15 -8
- data/lib/moribus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5e4d15715c31a7fc3c7fbc7e5374f27271d735a
|
4
|
+
data.tar.gz: def9ae949ad1d956852b70e23f8652bd2d977f42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9fe7bfc87c9a2be5e04781d5345c87bb3b10ba6ed9925641cb60bc80e1e93eb07a1a737c9ffbf2e9e60872451753a27cd42e601245741f85b7b47f26a3c4bc
|
7
|
+
data.tar.gz: c26e4d4ab22786a432b6d6aec34d932b2466b921a0c860b5bf71cd67c9811872bc9c492950e65c0dd3f0aa0406be5d48aa3c681e80a8153928eb1fd2d9872f83
|
data/.simplecov
CHANGED
@@ -12,7 +12,7 @@ SimpleCov.start do
|
|
12
12
|
# Fail the build when coverage is weak:
|
13
13
|
at_exit do
|
14
14
|
SimpleCov.result.format!
|
15
|
-
threshold, actual = 97.
|
15
|
+
threshold, actual = 97.15, SimpleCov.result.covered_percent
|
16
16
|
if actual < threshold
|
17
17
|
msg = "\nLow coverage: "
|
18
18
|
msg << red("#{actual}%")
|
@@ -28,7 +28,7 @@ module Moribus
|
|
28
28
|
ActiveRecord::Reflection.add_reflection self, alias_name, reflection
|
29
29
|
else
|
30
30
|
# Rails 4.0.x behavior:
|
31
|
-
reflections[alias_name] =
|
31
|
+
reflections[alias_name] = reflections[association_name]
|
32
32
|
end
|
33
33
|
alias_association_methods(alias_name, reflection)
|
34
34
|
reflection
|
@@ -77,15 +77,22 @@ module Moribus
|
|
77
77
|
|
78
78
|
# Generate SQL statement to be used to update 'is_current' state of record to false.
|
79
79
|
def current_to_false_sql_statement
|
80
|
-
klass
|
81
|
-
is_current_col
|
82
|
-
|
83
|
-
lock_value
|
84
|
-
|
80
|
+
klass = self.class
|
81
|
+
is_current_col = klass.columns.detect { |c| c.name == "is_current" }
|
82
|
+
lock_column_name = klass.locking_column
|
83
|
+
lock_value = respond_to?(lock_column_name) && send(lock_column_name).to_i
|
84
|
+
lock_column = if lock_value
|
85
|
+
klass.columns.detect { |c| c.name == lock_column_name }
|
86
|
+
else
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
id_column = klass.columns.detect { |c| c.name == klass.primary_key }
|
90
|
+
quoted_lock_column = klass.connection.quote_column_name(lock_column_name)
|
91
|
+
|
85
92
|
"UPDATE #{klass.quoted_table_name} SET \"is_current\" = #{klass.quote_value(false, is_current_col)} ".tap do |sql|
|
86
|
-
sql << ", #{
|
87
|
-
sql << "WHERE #{klass.quoted_primary_key} = #{klass.quote_value(@_before_to_new_record_values[:id],
|
88
|
-
sql << "AND #{
|
93
|
+
sql << ", #{quoted_lock_column} = #{klass.quote_value(lock_value + 1, lock_column)} " if lock_value
|
94
|
+
sql << "WHERE #{klass.quoted_primary_key} = #{klass.quote_value(@_before_to_new_record_values[:id], id_column)} "
|
95
|
+
sql << "AND #{quoted_lock_column} = #{klass.quote_value(lock_value, lock_column)}" if lock_value
|
89
96
|
end
|
90
97
|
end
|
91
98
|
private :current_to_false_sql_statement
|
data/lib/moribus/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
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: 2015-01-
|
13
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|