Class: Libertree::Model::PostLike
- Inherits:
-
Object
- Object
- Libertree::Model::PostLike
- Defined in:
- lib/libertree/model/post-like.rb
Class Method Summary collapse
Instance Method Summary collapse
- #after_create ⇒ Object
- #before_destroy ⇒ Object
-
#delete ⇒ Object
TODO: the correct method to call is “destroy”.
- #delete_cascade ⇒ Object
- #forests ⇒ Object
- #local? ⇒ Boolean
- #member ⇒ Object
- #post ⇒ Object
Class Method Details
.create(*args) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/libertree/model/post-like.rb', line 53 def self.create(*args) like = super like.post.notify_about_like like account = like.member.account if account like.post.mark_as_read_by account end like end |
Instance Method Details
#after_create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/libertree/model/post-like.rb', line 4 def after_create super if self.local? && self.post.distribute? Libertree::Model::Job.create_for_forests( { task: 'request:POST-LIKE', params: { 'post_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/post-like.rb', line 29 def before_destroy if self.local? && self.post.distribute? Libertree::Model::Job.create_for_forests( { task: 'request:POST-LIKE-DELETE', params: { 'post_like_id' => self.id, } }, *self.forests ) end super end |
#delete ⇒ Object
TODO: the correct method to call is “destroy”
43 44 45 46 |
# File 'lib/libertree/model/post-like.rb', line 43 def delete self.before_destroy super end |
#delete_cascade ⇒ Object
48 49 50 51 |
# File 'lib/libertree/model/post-like.rb', line 48 def delete_cascade self.before_destroy DB.dbh[ "SELECT delete_cascade_post_like(?)", self.id ].get end |
#forests ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/libertree/model/post-like.rb', line 63 def forests if self.post.remote? self.post.server.forests else Libertree::Model::Forest.all_local_is_member end end |
#local? ⇒ Boolean
17 18 19 |
# File 'lib/libertree/model/post-like.rb', line 17 def local? self.remote_id.nil? end |
#member ⇒ Object
21 22 23 |
# File 'lib/libertree/model/post-like.rb', line 21 def member @member ||= Member[self.member_id] end |
#post ⇒ Object
25 26 27 |
# File 'lib/libertree/model/post-like.rb', line 25 def post @post ||= Post[self.post_id] end |