Class: Faalis::Comments::Comment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Faalis::Comments::Comment
- Defined in:
- app/models/faalis/comments/comment.rb
Class Method Summary collapse
-
.build_from(obj, user_id, comment) ⇒ Object
Helper class method that allows you to build a comment by passing a commentable object, a user_id, and comment text example in readme.
-
.find_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up a commentable object given the commentable class name and id.
Instance Method Summary collapse
-
#has_children? ⇒ Boolean
helper method to check if a comment has children.
Class Method Details
.build_from(obj, user_id, comment) ⇒ Object
Helper class method that allows you to build a comment by passing a commentable object, a user_id, and comment text example in readme
22 23 24 25 26 27 |
# File 'app/models/faalis/comments/comment.rb', line 22 def self.build_from(obj, user_id, comment) new \ commentable: obj, body: comment, user_id: user_id end |
.find_commentable(commentable_str, commentable_id) ⇒ Object
Helper class method to look up a commentable object given the commentable class name and id
48 49 50 |
# File 'app/models/faalis/comments/comment.rb', line 48 def self.find_commentable(commentable_str, commentable_id) commentable_str.constantize.find(commentable_id) end |
Instance Method Details
#has_children? ⇒ Boolean
helper method to check if a comment has children
30 31 32 |
# File 'app/models/faalis/comments/comment.rb', line 30 def has_children? self.children.any? end |