ecm_downloads2 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2b268ab91800af05cec6fd7f1a143b7a54f89d2
|
|
4
|
+
data.tar.gz: 514774402fcfedbd82e1d798f4f976750d30e40b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19ad40bf31c60ea2e18e311a93ebe3c04e50cd9e0a7f17a0335f92b0a6d9f562b9a11608dfdafa977220e4051100af616329092ea6a1317abca245b5ae6ff1a2
|
|
7
|
+
data.tar.gz: 14a8656a6017cacb9e4008b82338b8575993ea6cce948ad25f3658744f10a671c23b1e07afc89b2ca4f8d2797e16e3053b9279104e70ef06b6ab4d83391b30b0
|
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
module FixUpdateCounters
|
|
2
|
-
def fix_updated_counters
|
|
3
|
-
self.changes.each {|key, value|
|
|
4
|
-
# key should match /master_files_id/ or /bibls_id/
|
|
5
|
-
# value should be an array ['old value', 'new value']
|
|
6
|
-
if key =~ /_id/
|
|
7
|
-
changed_class = key.sub(/_id/, '')
|
|
8
|
-
|
|
9
|
-
# Get real class of changed attribute, so work both with namespaced/normal models
|
|
10
|
-
klass = self.association(changed_class.to_sym).klass
|
|
11
|
-
|
|
12
|
-
# Try to get counter cache from association options
|
|
13
|
-
begin
|
|
14
|
-
counter_name = self.association(changed_class.to_sym).options[:counter_cache]
|
|
15
|
-
rescue
|
|
16
|
-
# Namespaced model return a slash, split it.
|
|
17
|
-
unless (counter_name = "#{self.class.name.underscore.pluralize.split("/")[1]}_count".to_sym)
|
|
18
|
-
counter_name = "#{self.class.name.underscore.pluralize}_count".to_sym
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
klass.decrement_counter(counter_name, value[0]) unless value[0] == nil
|
|
24
|
-
klass.increment_counter(counter_name, value[1]) unless value[1] == nil
|
|
25
|
-
end
|
|
26
|
-
}
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
ActiveRecord::Base.send(:include, FixUpdateCounters)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
1
|
class Ecm::Downloads::Download < ActiveRecord::Base
|
|
35
2
|
# db settings
|
|
36
3
|
self.table_name = 'ecm_downloads_downloads'
|
|
@@ -44,8 +11,7 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
|
44
11
|
|
|
45
12
|
# associations
|
|
46
13
|
belongs_to :ecm_downloads_download_category,
|
|
47
|
-
:
|
|
48
|
-
:counter_cache => :ecm_downloads_downloads_count,
|
|
14
|
+
class_name: Ecm::Downloads::DownloadCategory,
|
|
49
15
|
inverse_of: :ecm_downloads_downloads
|
|
50
16
|
|
|
51
17
|
# attibutes
|
|
@@ -55,7 +21,6 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
|
55
21
|
:name if respond_to? :attr_accessible
|
|
56
22
|
|
|
57
23
|
# callbacks
|
|
58
|
-
after_update :fix_updated_counters
|
|
59
24
|
before_update :fix_updated_position, :if => Proc.new { |d| !position.blank? && d.ecm_downloads_download_category_id_changed? }
|
|
60
25
|
|
|
61
26
|
# friendly id
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ecm_downloads2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Roberto Vasquez Angel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|