Class: Libertree::Model::CommentLike
- Inherits:
-
Object
- Object
- Libertree::Model::CommentLike
- Defined in:
- lib/libertree/model/comment-like.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_create ⇒ Object
- #before_destroy ⇒ Object
- #comment ⇒ Object
-
#delete ⇒ Object
TODO: the correct method to call is “destroy”.
- #delete_cascade ⇒ Object
- #forests ⇒ Object
- #local? ⇒ Boolean
- #member ⇒ Object
Class Method Details
.create(*args) ⇒ Object
53 54 55 56 57 |
# File 'lib/libertree/model/comment-like.rb', line 53 def self.create(*args) like = super like.comment.notify_about_like like like end |
Instance Method Details
#after_create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/libertree/model/comment-like.rb', line 4 def after_create super if self.local? && self.comment.post.distribute? Libertree::Model::Job.create_for_forests( { task: 'request:COMMENT-LIKE', params: { 'comment_like_id' => self.id, } }, *self.forests ) end end |
#before_destroy ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/libertree/model/comment-like.rb', line 29 def before_destroy if self.local? && self.comment.post.distribute? Libertree::Model::Job.create_for_forests( { task: 'request:COMMENT-LIKE-DELETE', params: { 'comment_like_id' => self.id, } }, *self.forests ) end super end |
#comment ⇒ Object
25 26 27 |
# File 'lib/libertree/model/comment-like.rb', line 25 def comment @comment ||= Comment[self.comment_id] end |
#delete ⇒ Object
TODO: the correct method to call is “destroy”
43 44 45 46 |
# File 'lib/libertree/model/comment-like.rb', line 43 def delete self.before_destroy super end |
#delete_cascade ⇒ Object
48 49 50 51 |
# File 'lib/libertree/model/comment-like.rb', line 48 def delete_cascade self.before_destroy DB.dbh[ "SELECT delete_cascade_comment_like(?)", self.id ].get end |
#forests ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/libertree/model/comment-like.rb', line 59 def forests if self.comment.post.remote? self.comment.post.server.forests else Libertree::Model::Forest.all_local_is_member end end |
#local? ⇒ Boolean
17 18 19 |
# File 'lib/libertree/model/comment-like.rb', line 17 def local? self.remote_id.nil? end |
#member ⇒ Object
21 22 23 |
# File 'lib/libertree/model/comment-like.rb', line 21 def member @member ||= Member[self.member_id] end |