Class: LcpRuby::Kanban::HostProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/kanban/host_provider.rb

Overview

Base class for kanban data providers. The platform always delegates to a provider — ‘DefaultProvider` for config-driven workflow/enum/belongs_to boards, or a host-app subclass for virtual / external / derived grouping.

Contract: see docs/design/kanban_view.md → “Host Provider Contract”. Required methods: ‘columns`, `fetch_records`. Required from Phase 2+: `move`. Phase 1 may raise NotImplementedError on `move` (board renders read-only). Optional: `can_move?`, `allowed_targets`, `swimlanes`, `fetch_records_2d`, `column_aggregate`, column management, quick create.

Direct Known Subclasses

DefaultProvider

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, model_definition:) ⇒ HostProvider

Returns a new instance of HostProvider.



15
16
17
18
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 15

def initialize(config:, model_definition:)
  @config = config || {}
  @model_definition = model_definition
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 13

def config
  @config
end

#model_definitionObject (readonly)

Returns the value of attribute model_definition.



13
14
15
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 13

def model_definition
  @model_definition
end

Instance Method Details

#allowed_targets(record:, user:) ⇒ Object

OPTIONAL. Hint to the UI: which target columns are reachable from the record’s current state? ‘nil` = no constraint (all columns allowed).



51
52
53
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 51

def allowed_targets(record:, user:)
  nil
end

#archive_column(column_value, user:) ⇒ Object

Raises:

  • (NotImplementedError)


84
85
86
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 84

def archive_column(column_value, user:)
  raise NotImplementedError, "#{self.class}#archive_column must be implemented"
end

#can_move?(record:, user:) ⇒ Boolean

OPTIONAL. Pre-drag gating. Affects ‘draggable` attribute at render time. Conservative default: allowed; final authority is `#move`.

Returns:

  • (Boolean)


45
46
47
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 45

def can_move?(record:, user:)
  true
end

#column_aggregate(column_value, records) ⇒ Object

OPTIONAL (Phase 4). Aggregated value for a column header.



67
68
69
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 67

def column_aggregate(column_value, records)
  nil
end

#columns(scope:, user:, context:) ⇒ Object

REQUIRED. Returns an Array<Kanban::Column> in display order. ‘scope` is the fully-filtered AR relation (policy, search, filters applied by the platform). `context` carries request state (`:locale`, `:params`, `:saved_filter`, `:view_group`, `:presenter_slug`, `:kanban_column`, `:kanban_page`).

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 25

def columns(scope:, user:, context:)
  raise NotImplementedError, "#{self.class}#columns must be implemented"
end

#create_column(attrs:, user:) ⇒ Object

OPTIONAL (Phase 5). Column management.

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 72

def create_column(attrs:, user:)
  raise NotImplementedError, "#{self.class}#create_column must be implemented"
end

#create_in_column(attrs:, column_value:, user:) ⇒ Object

OPTIONAL (Phase 2). Quick create.

Raises:

  • (NotImplementedError)


89
90
91
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 89

def create_in_column(attrs:, column_value:, user:)
  raise NotImplementedError, "#{self.class}#create_in_column must be implemented"
end

#delete_column(column_value, user:) ⇒ Object

Raises:

  • (NotImplementedError)


80
81
82
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 80

def delete_column(column_value, user:)
  raise NotImplementedError, "#{self.class}#delete_column must be implemented"
end

#fetch_records(scope:, columns:, user:, context:) ⇒ Object

REQUIRED. Returns Hash=> [records] — records bucketed into the columns from ‘#columns`. `columns:` is the same array; the provider may iterate or query per column.

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 32

def fetch_records(scope:, columns:, user:, context:)
  raise NotImplementedError, "#{self.class}#fetch_records must be implemented"
end

#fetch_records_2d(scope:, columns:, swimlanes:, user:, context:) ⇒ Object

OPTIONAL (Phase 3). 2D bucketing.

Raises:

  • (NotImplementedError)


62
63
64
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 62

def fetch_records_2d(scope:, columns:, swimlanes:, user:, context:)
  raise NotImplementedError, "#{self.class}#fetch_records_2d must be implemented"
end

#move(record:, target_column:, target_swimlane: nil, target_position: nil, user:, comment: nil) ⇒ Object

REQUIRED in Phase 2+. Phase 1 may raise NotImplementedError → board renders read-only (every card receives ‘draggable=false`). Returns a `Kanban::MoveResult`.

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 39

def move(record:, target_column:, target_swimlane: nil, target_position: nil, user:, comment: nil)
  raise NotImplementedError, "#{self.class}#move must be implemented"
end

#rename_column(column_value, new_label:, user:) ⇒ Object

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 76

def rename_column(column_value, new_label:, user:)
  raise NotImplementedError, "#{self.class}#rename_column must be implemented"
end

#swimlanes(scope:, user:, context:) ⇒ Object

OPTIONAL (Phase 3). Swimlane row definitions; ‘nil` when no swimlane dimension. Phase 1 controllers never call this.



57
58
59
# File 'lib/lcp_ruby/kanban/host_provider.rb', line 57

def swimlanes(scope:, user:, context:)
  nil
end