Module: Plutonium::Kanban::Grouping
- Defined in:
- lib/plutonium/kanban/grouping.rb
Overview
The two primitives every kanban rendering path shares: which columns a board has, and how a column's scope narrows a relation.
There is deliberately no call that groups a whole relation in one go.
One existed and had no callers: KanbanActions renders columns
independently — each is its own lazy turbo-frame with its own per_column
cap and count — so a whole-board grouper only ever duplicated that logic
while quietly counting and limiting every column on every request.
Class Method Summary collapse
-
.apply_scope(relation, scope) ⇒ Object
Applies a column scope to a relation.
-
.resolve_columns(board, context) ⇒ Object
Resolves the column list from a board.
Class Method Details
.apply_scope(relation, scope) ⇒ Object
Applies a column scope to a relation. Symbol → relation.public_send(sym) (named scope) Proc → relation.instance_exec(&scope) (inline lambda, e.g. -> { where(status: "todo") }) nil → relation unchanged
28 29 30 31 32 33 34 35 |
# File 'lib/plutonium/kanban/grouping.rb', line 28 def apply_scope(relation, scope) case scope when Symbol then relation.public_send(scope) when Proc then relation.instance_exec(&scope) when nil then relation else raise ArgumentError, "Unsupported column scope: #{scope.inspect} (expected Symbol, Proc, or nil)" end end |
.resolve_columns(board, context) ⇒ Object
Resolves the column list from a board. For dynamic boards, evaluates the columns_block against the context (which exposes current_user, params, etc. via delegation to view_context).
19 20 21 22 |
# File 'lib/plutonium/kanban/grouping.rb', line 19 def resolve_columns(board, context) return board.columns unless board.dynamic? Array(context.instance_exec(&board.columns_block)).flatten end |