acts_as_commentable2 7.1.0.1 → 7.2.0.1
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 +4 -4
- data/README.rdoc +1 -0
- data/lib/comment_methods.rb +2 -1
- data/lib/commentable_methods.rb +13 -11
- data/lib/generators/comment/comment_generator.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1025e16458f3cbd4cf626aa47ac5bc333d91d171af2bc7927cede9a77a4b6635
|
4
|
+
data.tar.gz: 35b6beb57cdbce25fe90c5224c5c107cd81290e34ca21269b51b6ce071a44611
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 673c8bd078e3446afe30687c0215f6d4bde83966b0a8c39538c1677977cc8de26c941b5c7bb6e54d88d4639a0ca6e3ecfd5df8d97134815c378a709ec5e6c5fc
|
7
|
+
data.tar.gz: 2a432e27973ec295786736f4049ad4352b7f07ff4e943652e584b04d46e4212830d4ff2b5eb6a5237e3523f2bcfcf6979b2bf7d233ef6dcb31b0aba5eec202fa
|
data/README.rdoc
CHANGED
data/lib/comment_methods.rb
CHANGED
@@ -29,7 +29,8 @@ module ActsAsCommentable
|
|
29
29
|
# Helper class method to look up all comments for
|
30
30
|
# commentable class name and commentable id.
|
31
31
|
def find_comments_for_commentable(commentable_str, commentable_id, role = 'comments')
|
32
|
-
where(['commentable_type = ? and commentable_id = ? and role = ?', commentable_str, commentable_id,
|
32
|
+
where(['commentable_type = ? and commentable_id = ? and role = ?', commentable_str, commentable_id,
|
33
|
+
role]).order('created_at DESC')
|
33
34
|
end
|
34
35
|
|
35
36
|
# Helper class method to look up a commentable object
|
data/lib/commentable_methods.rb
CHANGED
@@ -2,8 +2,8 @@ require 'active_record'
|
|
2
2
|
|
3
3
|
# ActsAsCommentable
|
4
4
|
module Juixe
|
5
|
-
module Acts
|
6
|
-
module Commentable
|
5
|
+
module Acts # :nodoc:
|
6
|
+
module Commentable # :nodoc:
|
7
7
|
def self.included(base)
|
8
8
|
base.extend ClassMethods
|
9
9
|
end
|
@@ -12,9 +12,9 @@ module Juixe
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def define_role_based_inflection(role)
|
15
|
-
return if method_defined?("#{role}_comments"
|
15
|
+
return if method_defined?(:"#{role}_comments")
|
16
16
|
|
17
|
-
has_many "#{role}_comments"
|
17
|
+
has_many :"#{role}_comments",
|
18
18
|
-> { where(role: role.to_s) },
|
19
19
|
**has_many_options(role)
|
20
20
|
end
|
@@ -44,13 +44,13 @@ module Juixe
|
|
44
44
|
class_attribute :comment_types
|
45
45
|
self.comment_types = (comment_roles.blank? ? [:comments] : comment_roles)
|
46
46
|
|
47
|
-
if
|
47
|
+
if comment_roles.blank?
|
48
|
+
has_many :comments, as: :commentable, dependent: :destroy, **join_options
|
49
|
+
else
|
48
50
|
comment_roles.each do |role|
|
49
51
|
define_role_based_inflection(role)
|
50
52
|
end
|
51
|
-
has_many :all_comments,
|
52
|
-
else
|
53
|
-
has_many :comments, **{ as: :commentable, dependent: :destroy }.merge(join_options)
|
53
|
+
has_many :all_comments, as: :commentable, dependent: :destroy, class_name: 'Comment', **join_options
|
54
54
|
end
|
55
55
|
|
56
56
|
comment_types.each do |role|
|
@@ -64,7 +64,9 @@ module Juixe
|
|
64
64
|
|
65
65
|
def self.find_#{method_name}_by_user(user)
|
66
66
|
commentable = self.base_class.name
|
67
|
-
Comment.where([
|
67
|
+
Comment.where([
|
68
|
+
"user_id = ? and commentable_type = ? and role = ?", user.id, commentable, "#{role}"
|
69
|
+
]).order("created_at DESC")
|
68
70
|
end
|
69
71
|
|
70
72
|
def #{method_name}_ordered_by_submitted
|
@@ -75,7 +77,7 @@ module Juixe
|
|
75
77
|
comment.role = "#{role}"
|
76
78
|
#{method_name} << comment
|
77
79
|
end
|
78
|
-
}
|
80
|
+
}, __FILE__, __LINE__ - 21
|
79
81
|
end
|
80
82
|
end
|
81
83
|
end
|
@@ -83,4 +85,4 @@ module Juixe
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
86
|
-
ActiveRecord::Base.
|
88
|
+
ActiveRecord::Base.include Juixe::Acts::Commentable
|
@@ -4,7 +4,7 @@ class CommentGenerator < Rails::Generators::Base
|
|
4
4
|
include Rails::Generators::Migration
|
5
5
|
|
6
6
|
def self.source_root
|
7
|
-
@
|
7
|
+
@source_root ||= File.expand_path('templates', __dir__)
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.next_migration_number(_path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_commentable2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cosmin Radoi, Jack Dempsey, Xelipe, Chris Eppstein
|
@@ -16,16 +16,16 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 7.
|
19
|
+
version: 7.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 7.
|
26
|
+
version: 7.2.0
|
27
27
|
description: Plugin/gem that provides comment functionality
|
28
|
-
email:
|
28
|
+
email: daniel.oconnor@gmail.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files:
|
@@ -46,7 +46,8 @@ files:
|
|
46
46
|
homepage: http://www.juixe.com/techknow/index.php/2006/06/18/acts-as-commentable-plugin/
|
47
47
|
licenses:
|
48
48
|
- MIT
|
49
|
-
metadata:
|
49
|
+
metadata:
|
50
|
+
rubygems_mfa_required: 'true'
|
50
51
|
rdoc_options: []
|
51
52
|
require_paths:
|
52
53
|
- lib
|
@@ -54,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
55
|
requirements:
|
55
56
|
- - ">="
|
56
57
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
+
version: 3.1.0
|
58
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
61
|
- - ">="
|
@@ -62,6 +63,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
version: '0'
|
63
64
|
requirements: []
|
64
65
|
rubygems_version: 3.6.2
|
65
|
-
specification_version:
|
66
|
+
specification_version: 4
|
66
67
|
summary: Plugin/gem that provides comment functionality
|
67
68
|
test_files: []
|