Module: ActsAsCommentable::Comment
- Included in:
- Comment
- Defined in:
- lib/comment_methods.rb
Overview
including this module into your Comment model will give you finders and named scopes useful for working with Comments. The named scopes are:
in_order: Returns comments in the order they were created (created_at ASC).
recent: Returns comments by how recently they were created (created_at DESC).
limit(N): Return no more than N comments.
Defined Under Namespace
Modules: Finders
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(comment_model) ⇒ Object
10 11 12 13 14 |
# File 'lib/comment_methods.rb', line 10 def self.included(comment_model) comment_model.extend Finders comment_model.scope :in_order, -> { comment_model.order('created_at ASC') } comment_model.scope :recent, -> { comment_model.reorder('created_at DESC') } end |
Instance Method Details
#is_comment_type?(type) ⇒ Boolean
16 17 18 |
# File 'lib/comment_methods.rb', line 16 def is_comment_type?(type) type.to_s == role.singularize.to_s end |