Class: Workarea::Admin::BlogCommentsViewModel
- Inherits:
-
ApplicationViewModel
- Object
- ApplicationViewModel
- Workarea::Admin::BlogCommentsViewModel
- Defined in:
- app/view_models/workarea/admin/blog_comments_view_model.rb
Instance Method Summary collapse
Instance Method Details
#blog ⇒ Object
39 40 41 42 |
# File 'app/view_models/workarea/admin/blog_comments_view_model.rb', line 39 def blog return nil unless blog_entry.present? blog_entry.blog end |
#blog_entry ⇒ Object
33 34 35 36 37 |
# File 'app/view_models/workarea/admin/blog_comments_view_model.rb', line 33 def blog_entry return nil unless [:content_blog_entry_id].present? @blog_entry ||= Content::BlogEntry.find_by(slug: [:content_blog_entry_id]) end |
#comments ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/view_models/workarea/admin/blog_comments_view_model.rb', line 9 def comments return @comments if defined?(@comments) comments = if [:content_blog_entry_id].present? blog_entry .comments .page([:page]) .per(per_page) .order_by([:built_sort]) else Content::BlogComment .page([:page]) .per(per_page) .order_by([:built_sort]) end @comments = PagedArray.from( comments, comments.current_page, per_page, comments.total_count ) end |