kasket 4.4.2 → 4.4.3

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: 17895bdaa6714332687123725db150ac6c57d5d7
4
- data.tar.gz: fc5bb65fe487c33a4c94a7ed28bee5bca3ad5c6b
3
+ metadata.gz: ba85f36144f05d60bbebcba8a11ff48b930d29cf
4
+ data.tar.gz: a0ac4b0539ecf1c19f700ec08318a17ea5f01c6f
5
5
  SHA512:
6
- metadata.gz: 2e7536fe46dae27055f76f25a3c0c013c67ee91b26f1c99402bd0b157c9d51c766c838583c62774eaed3fa5de7ef3590a1618f9538c99a488a653aa082d1dbbc
7
- data.tar.gz: 7001132cd08953919dc8531e3af838398025f5daae680ab76cbcee8f2ff8f051b570400c96e6794424f1b7c95a8a64f8a58d0695dd861d96b27e547d9a29fdd4
6
+ metadata.gz: a25702c95434941d087060eb6c6cab9dd3843701efe293709cdd69de9c6a0ef2d11c9f194a69e9d4c4f703f3e3e1f2ede9970bb58cee42baa8db4b39aee43458
7
+ data.tar.gz: c68f3966ba94bc372ce16d7e2fd8996ed009ff362f49355181cdf471764b387d373cf540dda854531bd568de2115978b37f54b75a3252ba73b74dce2af46b606
@@ -1,5 +1,5 @@
1
1
  module Kasket
2
- VERSION = '4.4.2'
2
+ VERSION = '4.4.3'
3
3
  class Version
4
4
  MAJOR = Kasket::VERSION.split('.')[0]
5
5
  MINOR = Kasket::VERSION.split('.')[1]
@@ -37,11 +37,12 @@ module Kasket
37
37
  end
38
38
  end
39
39
 
40
- def kasket_keys
40
+ def kasket_keys(options = {})
41
41
  attribute_sets = [attributes.symbolize_keys]
42
42
 
43
+ previous_changes = options[:previous_changes] || previous_changes()
43
44
  if previous_changes.present?
44
- old_attributes = Hash[*previous_changes.map {|attribute, values| [attribute, values[0]]}.flatten].symbolize_keys
45
+ old_attributes = Hash[*previous_changes.map { |attribute, values| [attribute, values[0]] }.flatten].symbolize_keys
45
46
  attribute_sets << old_attributes.reverse_merge(attribute_sets[0])
46
47
  end
47
48
 
@@ -71,21 +72,32 @@ module Kasket
71
72
  end
72
73
  end
73
74
 
74
- def clear_kasket_indices
75
- kasket_keys.each do |key|
75
+ def clear_kasket_indices(options = {})
76
+ kasket_keys(options).each do |key|
76
77
  Kasket.cache.delete(key)
77
78
  end
78
79
  end
79
80
 
80
- def reload(*args)
81
+ def reload(*)
81
82
  clear_kasket_indices
82
83
  super
83
84
  end
84
85
 
85
- def update_column(*args)
86
- result = super
87
- clear_kasket_indices
88
- result
86
+ if ActiveRecord::VERSION::MAJOR == 3
87
+ def update_column(column, value)
88
+ previous_changes = {column => [attributes[column.to_s], value]}
89
+ result = super
90
+ clear_kasket_indices(previous_changes: previous_changes)
91
+ result
92
+ end
93
+ else
94
+ def update_columns(new_attributes)
95
+ previous_attributes = attributes
96
+ previous_changes = new_attributes.each_with_object({}) { |(k, v), all| all[k] = [previous_attributes[k.to_s], v] }
97
+ result = super
98
+ clear_kasket_indices(previous_changes: previous_changes)
99
+ result
100
+ end
89
101
  end
90
102
 
91
103
  def kasket_after_commit_dummy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kasket
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.2
4
+ version: 4.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-27 00:00:00.000000000 Z
12
+ date: 2017-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord