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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff0aab79e8583ad02f5eeea9b364f1675d893399
4
- data.tar.gz: 2c299a91b8eb26c99a91896b01100dcd04626409
3
+ metadata.gz: e5e4d15715c31a7fc3c7fbc7e5374f27271d735a
4
+ data.tar.gz: def9ae949ad1d956852b70e23f8652bd2d977f42
5
5
  SHA512:
6
- metadata.gz: c66b62b01b54222d549dbd8e038d3b073cf850a9f394450dcde325bf32d644e796ce234720c53cbebd1c0f8cd156a5479571b5d59021798fc5b48f1a5ecdbbe8
7
- data.tar.gz: 86c8695bd44971914bc00f5f60fd72a1a697a1625810cafd9575b2287ee3e2112b74b0c51e92411868609e5f3e3d48dba35e2bf81c032216efbf40fd9f1d2a16
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.118, SimpleCov.result.covered_percent
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] = reflection
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 = self.class
81
- is_current_col = klass.columns.detect{|c| c.name == "is_current" }
82
- lock_col = klass.locking_column
83
- lock_value = respond_to?(lock_col) && send(lock_col).to_i
84
- quoted_lock_col = klass.connection.quote_column_name(lock_col)
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 << ", #{quoted_lock_col} = #{klass.quote_value(lock_value + 1, lock_col)} " if lock_value
87
- sql << "WHERE #{klass.quoted_primary_key} = #{klass.quote_value(@_before_to_new_record_values[:id], "id")} "
88
- sql << "AND #{quoted_lock_col} = #{klass.quote_value(lock_value, lock_col)}" if lock_value
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
@@ -1,3 +1,3 @@
1
1
  module Moribus # :nodoc:
2
- VERSION = "0.2.0" # :nodoc:
2
+ VERSION = "0.2.1" # :nodoc:
3
3
  end
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.0
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-20 00:00:00.000000000 Z
13
+ date: 2015-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails