Class: Thredded::MessageboardGroupView
- Inherits:
-
Object
- Object
- Thredded::MessageboardGroupView
- Defined in:
- app/view_models/thredded/messageboard_group_view.rb
Overview
A view model for a page of MessageboardGroupViews.
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#messageboards ⇒ Object
readonly
Returns the value of attribute messageboards.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(group, messageboards) ⇒ MessageboardGroupView
constructor
A new instance of MessageboardGroupView.
Constructor Details
#initialize(group, messageboards) ⇒ MessageboardGroupView
Returns a new instance of MessageboardGroupView.
22 23 24 25 |
# File 'app/view_models/thredded/messageboard_group_view.rb', line 22 def initialize(group, ) @group = group @messageboards = end |
Instance Attribute Details
#group ⇒ Object (readonly)
Returns the value of attribute group.
7 8 9 |
# File 'app/view_models/thredded/messageboard_group_view.rb', line 7 def group @group end |
#messageboards ⇒ Object (readonly)
Returns the value of attribute messageboards.
7 8 9 |
# File 'app/view_models/thredded/messageboard_group_view.rb', line 7 def @messageboards end |
Class Method Details
.grouped(messageboard_scope) ⇒ Array<MessageboardGroupView>
11 12 13 14 15 16 17 18 |
# File 'app/view_models/thredded/messageboard_group_view.rb', line 11 def self.grouped() .preload(last_topic: [:last_user]) .eager_load(:group) .order(Arel.sql('COALESCE(thredded_messageboard_groups.position, 0) ASC, thredded_messageboard_groups.id ASC')) .ordered .group_by(&:group) .map { |(group, )| MessageboardGroupView.new(group, ) } end |