acts_as_commentable_more 1.2.9 → 1.2.10

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: 672806220d9adb336f161186d27b0efa7712f0c9
4
- data.tar.gz: 10235ad9b411cfd878c26c7c75bfaabc47efc911
3
+ metadata.gz: 2750b089cf878b76a9fe9b4389c9bbf5e0024e6f
4
+ data.tar.gz: 4ab4b84728c4d3a96ce1937196143dc511bc15df
5
5
  SHA512:
6
- metadata.gz: b38325194551c42e0b1f47e38fe4c64f76294dd9b16852fa6e02d847a83fde4de6757b0462e9a82c934674062fea509c935ad7dc8e3fed7714eb49b2d6e9c5a3
7
- data.tar.gz: 4ebb78f27f14789e26d5fcec562c15651dad5281895efa4968ad9504d8405c75fadad88d644f94d298e9276daef54ec8112c89a1f1657d54dad9506c883296b9
6
+ metadata.gz: 59387153a16d1a78b6d28ac39b4e1a8418864abe917c85f12cfcb31e806b22dcb729d2638d20867ed0f8a8024fdd837b0aa84e133481e1674b769ad21847b686
7
+ data.tar.gz: d53649cda904537fa2eac58b6babe7ffd9fe789d9f77168f8ba72bb5b3ab912d509f33fa40bc14fde3a3e82f7d92936a0b8790d8e25a5b01bba817c461a51a50
@@ -15,7 +15,7 @@ module ActsAsCommentableMore
15
15
  mattr_accessor :aacm_association_options
16
16
 
17
17
  default_commentable_options = { types: [], options: {}, as: nil, counter_cache: true }
18
- default_association_options = { as: :commentable, dependent: :destroy, class_name: 'Comment' }
18
+ default_association_options = { as: :commentable, dependent: :destroy, class_name: 'Comment', order_by: {} }
19
19
 
20
20
  self.aacm_commentable_options = default_commentable_options.merge(args.extract_options!)
21
21
  self.aacm_association_options = default_association_options.merge(aacm_commentable_options[:options].compact)
@@ -16,13 +16,15 @@ module ActsAsCommentableMore
16
16
  end
17
17
 
18
18
  def define_role_based_inflection_4(role, commantable_name, association_comment_name)
19
+ order_by_attrs = aacm_association_options[:order_by]
19
20
  has_many "#{association_comment_name}".to_sym,
20
- -> { includes(commantable_name, :user).where(role: role) },
21
+ -> { includes(commantable_name, :user).where(role: role).order(order_by_attrs) },
21
22
  has_many_options(role)
22
23
  end
23
24
 
24
25
  def has_many_options(role)
25
- { before_add: Proc.new { |post, comment| comment.role = role } }.merge(aacm_association_options)
26
+ association_options = aacm_association_options.except(:order_by)
27
+ { before_add: Proc.new { |post, comment| comment.role = role } }.merge(association_options)
26
28
  end
27
29
 
28
30
  end
@@ -8,7 +8,7 @@ module ActsAsCommentableMore
8
8
  aacm_commentable_options[:comment_model]
9
9
  .includes(aacm_association_options[:as].to_sym, :user)
10
10
  .where(aacm_association_options[:as].to_sym => self)
11
- .order(created_at: :desc)
11
+ .order(aacm_association_options[:order_by])
12
12
  end
13
13
  end
14
14
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsCommentableMore
2
- VERSION = "1.2.9"
2
+ VERSION = "1.2.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_commentable_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - piya23300
8
8
  autorequire: acts_as_commentable_more
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-03 00:00:00.000000000 Z
11
+ date: 2015-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake