ecm_downloads2 1.2.1 → 1.2.2

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: a740d28eefa04a2194af86f09a01ddb42365ab71
4
- data.tar.gz: 157a2a3b52457a5e7e225f89c909a6deb3ff90a3
3
+ metadata.gz: c2b268ab91800af05cec6fd7f1a143b7a54f89d2
4
+ data.tar.gz: 514774402fcfedbd82e1d798f4f976750d30e40b
5
5
  SHA512:
6
- metadata.gz: 5ec0f5c609ecef57831c1c4d40b599123d75f8389ab459cffaed6118892cbd3f6c213674850393f856da427870345ed7a57b525dd79e0fa26567937856a9a72a
7
- data.tar.gz: a0d9eeed82eb191855a4e2b1f93fd9d1ce24fdb34a3659c0671f17036c4c709763946da5247120f3ccd28ac9d3b1d39158c75867e1b3ef8342b387d7ce1ae62f
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
- :class_name => Ecm::Downloads::DownloadCategory,
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
@@ -43,6 +43,10 @@ class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
43
43
  validates :locale, :absence => true,
44
44
  :unless => :root?
45
45
 
46
+ def ecm_downloads_downloads_count
47
+ ecm_downloads_downloads.count
48
+ end
49
+
46
50
  def human
47
51
  name
48
52
  end
@@ -1,6 +1,6 @@
1
1
  module Ecm
2
2
  module Downloads
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
6
6
 
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.1
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-17 00:00:00.000000000 Z
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails