Class: LcpRuby::Metadata::PresenterDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/metadata/presenter_definition.rb

Constant Summary collapse

CARD_NAMED_FIELD_KEYS =
%w[
  title_field subtitle_field description_field
  image_field image_alt_field
  avatar_field avatar_alt_field
  color_field
].freeze
BATCH_INHERITABLE_KEYS =
%w[name type icon confirm confirm_message style action_class label].freeze
BATCH_SKIP_DERIVATION_TYPES =
%w[dialog transition].freeze
DEFAULT_FORM_ACTIONS =
[
  { "name" => "save", "type" => "built_in", "style" => "primary" }.freeze,
  { "name" => "cancel", "type" => "built_in", "style" => "secondary" }.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ PresenterDefinition

Returns a new instance of PresenterDefinition.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 20

def initialize(attrs = {})
  @name = attrs[:name].to_s
  @model = attrs[:model].to_s
  @label = attrs[:label] || @name.humanize
  @slug = attrs[:slug]
  @icon = attrs[:icon]
  # #15 — Shorthand for ordering single-presenter models in the auto-menu
  # without creating an explicit view group YAML. Used by
  # Loader#auto_create_view_groups to override the default
  # `AUTO_VIEW_GROUP_POSITION_BASE + alphabetical_index` position.
  # Ignored when an explicit view group already covers the model.
  @menu_position = attrs[:menu_position]&.to_i
  # B19 — Canonical-presenter flag for multi-presenter models. When a
  # model has more than one presenter, `link: true` / `link_to: :show`
  # resolves to the one marked `default: true`. Validator enforces
  # exactly one default per model and rejects ambiguous configs.
  # Coerced via ActiveModel::Type::Boolean so YAML idioms like `yes` /
  # `"true"` / `1` map to true; nil and unset keys remain false.
  @default = ActiveModel::Type::Boolean.new.cast(attrs[:default]) == true
  # Public *_config accessors are sanitized (no _*_source_loc keys)
  # so DSL- vs YAML-loaded presenters compare equal. The raw
  # variants (with source-locs) are preserved for i18n_check
  # Phase 3a iterators (each_section, each_column, …).
  @raw_index_config = HashUtils.stringify_deep(attrs[:index_config] || {})
  @raw_show_config = HashUtils.stringify_deep(attrs[:show_config] || {})
  @raw_form_config = HashUtils.stringify_deep(attrs[:form_config] || {})
  @raw_search_config = HashUtils.stringify_deep(attrs[:search_config] || {})
  @raw_actions_config = HashUtils.stringify_deep(attrs[:actions_config] || {})
  @index_config = HashUtils.strip_source_locs(@raw_index_config)
  @show_config = HashUtils.strip_source_locs(@raw_show_config)
  @form_config = HashUtils.strip_source_locs(@raw_form_config)
  @search_config = HashUtils.strip_source_locs(@raw_search_config)
  @actions_config = HashUtils.strip_source_locs(@raw_actions_config)
  @options = HashUtils.stringify_deep(attrs[:options] || {})
  @dialog_config = HashUtils.stringify_deep(attrs[:dialog_config] || {})
  @export_config = HashUtils.stringify_deep(attrs[:export_config] || {})
  @import_config = HashUtils.stringify_deep(attrs[:import_config] || {})
  @controller_name = attrs[:controller]
  @action_controllers = HashUtils.stringify_deep(attrs[:action_controllers] || {})
  @record_aliases = HashUtils.stringify_deep(attrs[:record_aliases] || {})
  @raw_hash = attrs[:raw_hash]
  @source_path = attrs[:source_path]
  @source_type = attrs[:source_type]
  # i18n_check Phase 3a — captured by PresenterBuilder#label, nil
  # for YAML-loaded presenters.
  @label_source_loc = attrs[:label_source_loc]

  validate!
end

Instance Attribute Details

#action_controllersObject (readonly)

Returns the value of attribute action_controllers.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def action_controllers
  @action_controllers
end

#actions_configObject (readonly)

Returns the value of attribute actions_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def actions_config
  @actions_config
end

#controller_nameObject (readonly)

Returns the value of attribute controller_name.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def controller_name
  @controller_name
end

#dialog_configObject (readonly)

Returns the value of attribute dialog_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def dialog_config
  @dialog_config
end

#export_configObject (readonly)

Returns the value of attribute export_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def export_config
  @export_config
end

#form_configObject (readonly)

Returns the value of attribute form_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def form_config
  @form_config
end

#iconObject (readonly)

Returns the value of attribute icon.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def icon
  @icon
end

#import_configObject (readonly)

Returns the value of attribute import_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def import_config
  @import_config
end

#index_configObject (readonly)

Returns the value of attribute index_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def index_config
  @index_config
end

#labelObject (readonly)

Returns the value of attribute label.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def label
  @label
end

#label_source_locObject (readonly)

Returns the value of attribute label_source_loc.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def label_source_loc
  @label_source_loc
end

Returns the value of attribute menu_position.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def menu_position
  @menu_position
end

#modelObject (readonly)

Returns the value of attribute model.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def options
  @options
end

#raw_hashObject (readonly)

Returns the value of attribute raw_hash.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def raw_hash
  @raw_hash
end

#record_aliasesObject (readonly)

Returns the value of attribute record_aliases.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def record_aliases
  @record_aliases
end

#search_configObject (readonly)

Returns the value of attribute search_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def search_config
  @search_config
end

#show_configObject (readonly)

Returns the value of attribute show_config.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def show_config
  @show_config
end

#slugObject (readonly)

Returns the value of attribute slug.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def slug
  @slug
end

#source_pathObject

Returns the value of attribute source_path.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def source_path
  @source_path
end

#source_typeObject

Returns the value of attribute source_type.



11
12
13
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 11

def source_type
  @source_type
end

Class Method Details

.extract_options(hash) ⇒ Object



678
679
680
681
682
683
684
685
686
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 678

def self.extract_options(hash)
  {
    "read_only" => hash["read_only"],
    "embeddable" => hash["embeddable"],
    "redirect_after" => hash["redirect_after"],
    "empty_value" => hash["empty_value"],
    "max_inline_actions" => hash["max_inline_actions"]
  }.compact
end

.from_hash(hash) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 70

def self.from_hash(hash)
  new(
    name: hash["name"],
    model: hash["model"],
    label: hash["label"],
    slug: hash["slug"],
    icon: hash["icon"],
    menu_position: hash["menu_position"],
    default: hash["default"],
    index_config: hash["index"] || {},
    show_config: hash["show"] || {},
    form_config: hash["form"] || {},
    search_config: hash["search"] || {},
    actions_config: hash["actions"] || {},
    options: extract_options(hash),
    dialog_config: hash["dialog"] || {},
    export_config: hash["export"] || {},
    import_config: hash["import"] || {},
    controller: hash["controller"],
    action_controllers: hash["action_controllers"],
    record_aliases: hash["record_aliases"],
    raw_hash: hash,
    label_source_loc: hash["_label_source_loc"]
  )
end

Instance Method Details

#action_controllers?Boolean

Returns:

  • (Boolean)


270
271
272
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 270

def action_controllers?
  action_controllers.any?
end

#advanced_filter_configObject



342
343
344
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 342

def advanced_filter_config
  search_config["advanced_filter"] || {}
end

#advanced_filter_enabled?Boolean

Returns:

  • (Boolean)


346
347
348
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 346

def advanced_filter_enabled?
  search_config["enabled"] && advanced_filter_config["enabled"] == true
end

#all_card_field_refsObject

Used by dependency_collector for eager loading and virtual_columns/collector for SELECT injection. Includes named-slot dot-paths so referenced associations are auto-included.



421
422
423
424
425
426
427
428
429
430
431
432
433
434
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 421

def all_card_field_refs
  return [] unless card_layout?

  card = card_config
  named = CARD_NAMED_FIELD_KEYS.filter_map { |k| card[k] }
  extra = (card["fields"] || []).filter_map { |f| f["field"] }
  # Kanban-specific fields that may be dot-paths in Phase 1+ (group_by;
  # in Phase 3 also swimlane_field). Including them in eager-load
  # collection prevents N+1s when an association is referenced via
  # a dot-path. Plain field names are no-ops for dependency collection.
  kanban = kanban_config
  kanban_refs = [ kanban["group_by"] ].compact
  named + extra + kanban_refs
end

#batch_actionsObject



317
318
319
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 317

def batch_actions
  @batch_actions ||= derive_batch_actions
end

#card_configObject



402
403
404
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 402

def card_config
  index_config["card"] || {}
end

#card_layout?Boolean

Single decision point for card-based layouts. Future card layouts (gallery, dashboard) get added here so callers don’t case over ‘index_layout`.

Returns:

  • (Boolean)


398
399
400
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 398

def card_layout?
  tiles? || kanban?
end

#collection_actionsObject



306
307
308
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 306

def collection_actions
  actions_config["collection"] || []
end

#custom_controller?Boolean

Returns:

  • (Boolean)


266
267
268
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 266

def custom_controller?
  controller_name.present?
end

#custom_routing?Boolean

Returns:

  • (Boolean)


274
275
276
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 274

def custom_routing?
  custom_controller? || action_controllers?
end

#default?Boolean

Marks this presenter as the canonical link target when its model has multiple presenters. Used by Presenter::Enrichment to resolve ‘link: true` / `link_to: :show` without an explicit per-link `link_presenter:` override.

Returns:

  • (Boolean)


109
110
111
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 109

def default?
  @default
end

#default_expandedObject



456
457
458
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 456

def default_expanded
  index_config.fetch("default_expanded", 0)
end

#default_viewObject



294
295
296
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 294

def default_view
  index_config["default_view"] || "table"
end

#each_columnObject

Yields index-column label kwargs (Tier 2 — runtime renders directly).



183
184
185
186
187
188
189
190
191
192
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 183

def each_column
  return enum_for(:each_column) unless block_given?
  cols = @raw_index_config && @raw_index_config["table_columns"]
  return unless cols.is_a?(Array)
  cols.each do |col|
    label = col["label"]
    next if label.nil?
    yield(label: label, field: col["field"], source: col["_label_source_loc"])
  end
end

#each_custom_actionObject

Yields custom action labels (Tier 1 — runtime queries ‘lcp_ruby.actions.form.<name>`). The key is per-action-name, shared across presenters with the same custom action.



249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 249

def each_custom_action
  return enum_for(:each_custom_action) unless block_given?
  # actions_config has shape: { "collection" => [...], "single" => [...], "form" => [...] }
  return unless @raw_actions_config.is_a?(Hash)
  @raw_actions_config.each_value do |group|
    next unless group.is_a?(Array)
    group.each do |action|
      next unless action["type"] == "custom" && action["label"]
      yield(label: action["label"], action: action["name"], source: action["_label_source_loc"])
    end
  end
end

#each_filterObject

Yields filter (predefined search) labels (Tier 2).



211
212
213
214
215
216
217
218
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 211

def each_filter
  return enum_for(:each_filter) unless block_given?
  filters = @raw_search_config && @raw_search_config["predefined_filters"]
  return unless filters.is_a?(Array)
  filters.each do |f|
    yield(label: f["label"], field: f["name"], source: f["_label_source_loc"])
  end
end

#each_form_field_overrideObject

Yields show/form field label OVERRIDES (when DSL set ‘label:` on a `field` inside a section; the runtime would otherwise use the model field’s resolved label). Tier 2.



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 197

def each_form_field_override
  return enum_for(:each_form_field_override) unless block_given?
  show_sections = (@raw_show_config && @raw_show_config["layout"]) || []
  form_sections = (@raw_form_config && @raw_form_config["sections"]) || []
  (show_sections + form_sections).each do |section|
    (section["fields"] || []).each do |fld|
      label = fld["label"]
      next if label.nil?
      yield(label: label, field: fld["field"], source: fld["_label_source_loc"])
    end
  end
end

#each_form_submit_labelObject

Yields form-action submit labels (‘form_action :create, submitting_label: “…”`).



171
172
173
174
175
176
177
178
179
180
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 171

def each_form_submit_label
  return enum_for(:each_form_submit_label) unless block_given?
  actions = @raw_actions_config && @raw_actions_config["form"]
  return unless actions.is_a?(Array)
  actions.each do |action|
    submit = action["submitting_label"]
    next if submit.nil?
    yield(label: submit, action: action["name"], source: action["_submitting_label_source_loc"])
  end
end

#each_saved_filterObject

Yields saved-filter / advanced-filter preset labels (Tier 2).



221
222
223
224
225
226
227
228
229
230
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 221

def each_saved_filter
  return enum_for(:each_saved_filter) unless block_given?
  presets = @raw_search_config &&
            @raw_search_config["advanced_filter"] &&
            @raw_search_config["advanced_filter"]["presets"]
  return unless presets.is_a?(Array)
  presets.each do |preset|
    yield(label: preset["label"], key: preset["name"], source: preset["_label_source_loc"])
  end
end

#each_sectionObject

Yields section titles from show + form configs. Show stores them in ‘layout` (each entry has `section`); form stores them in `sections` (each entry has `title`). Internal builder shapes verified by inspecting `to_hash` output of a fixture DSL.

‘section_key` resolution mirrors `LayoutHelper#resolve_section_title`: explicit `section_key:` (DSL `key:` keyword) wins verbatim, otherwise the literal title is parameterized. Sections may declare `key:` alone without a title (per School audit fix #7); for those we synthesize `label: section_key.humanize` so the walker compares against the runtime humanize-default fallback (`I18n.t default: key.humanize`) and emits `:missing_translation`, not `:literal_in_dsl`.



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 151

def each_section
  return enum_for(:each_section) unless block_given?
  show_sections = (@raw_show_config && @raw_show_config["layout"]) || []
  form_sections = (@raw_form_config && @raw_form_config["sections"]) || []
  (show_sections + form_sections).each do |section|
    raw_title = section["section"] || section["title"]
    explicit_key = section["section_key"]
    next if raw_title.nil? && explicit_key.nil?

    section_key = if explicit_key.present?
      explicit_key.to_s
    else
      raw_title.to_s.parameterize(separator: "_")
    end
    label = raw_title || section_key.humanize
    yield(label: label, section_key: section_key, source: section["_label_source_loc"])
  end
end

#each_stepObject



241
242
243
244
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 241

def each_step
  enum_for(:each_step) unless block_given?
  # No-op in Phase 3a — see docstring.
end

#each_tabObject

Yields tab labels. The current LCP DSL has no top-level ‘tab` / `step` builders that take a `label:` kwarg (per §I inventory); this iterator is a no-op until that surface is added. Kept as a placeholder for forward-compat.



236
237
238
239
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 236

def each_tab
  enum_for(:each_tab) unless block_given?
  # No-op in Phase 3a — see docstring.
end

#each_view_descriptionObject

Yields per-view description text. Views: index, show, form (and legacy aliases new/edit which map to form).



129
130
131
132
133
134
135
136
137
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 129

def each_view_description
  return enum_for(:each_view_description) unless block_given?
  { index: @raw_index_config, show: @raw_show_config, form: @raw_form_config }.each do |view, cfg|
    desc = cfg && cfg["description"]
    next if desc.nil?
    source = cfg["_description_source_loc"]
    yield(label: desc, view: view, source: source)
  end
end

#embeddable?Boolean

Returns:

  • (Boolean)


278
279
280
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 278

def embeddable?
  options["embeddable"] == true
end

#export_csv_delimiterObject



504
505
506
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 504

def export_csv_delimiter
  export_config["csv_delimiter"] || ","
end

#export_enabled?Boolean

Returns:

  • (Boolean)


484
485
486
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 484

def export_enabled?
  export_config.present?
end

#export_fields_ceilingObject



500
501
502
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 500

def export_fields_ceiling
  export_config["fields"]
end

#export_formatsObject



488
489
490
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 488

def export_formats
  export_config["formats"] || [ "csv" ]
end

#export_max_recordsObject



492
493
494
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 492

def export_max_records
  export_config["max_records"] || 10_000
end

#export_save_history?Boolean

Returns:

  • (Boolean)


496
497
498
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 496

def export_save_history?
  export_config["save_history"] == true
end

#form_actionsObject



326
327
328
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 326

def form_actions
  @form_actions ||= derive_form_actions
end

#group_by_configObject



354
355
356
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 354

def group_by_config
  index_config["group_by"] || []
end

#group_limitObject



362
363
364
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 362

def group_limit
  index_config["limit"]
end

#group_row_clickObject



366
367
368
369
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 366

def group_row_click
  rc = index_config["row_click"]
  rc.is_a?(Hash) && rc.key?("mode") ? rc : nil
end

#grouped?Boolean

Returns:

  • (Boolean)


384
385
386
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 384

def grouped?
  index_layout == :grouped
end

#grouped_query?Boolean

Returns:

  • (Boolean)


350
351
352
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 350

def grouped_query?
  index_config["query_mode"] == "grouped"
end

#has_search_parameters?Boolean

Returns:

  • (Boolean)


338
339
340
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 338

def has_search_parameters?
  search_config["parameters"].is_a?(Array) && search_config["parameters"].any?
end

#has_show_sections?Boolean

Returns:

  • (Boolean)


286
287
288
289
290
291
292
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 286

def has_show_sections?
  sc = show_config
  return false if sc.blank?

  (sc["layout"].is_a?(Array) && sc["layout"].any?) ||
    (sc["sections"].is_a?(Array) && sc["sections"].any?)
end

#having_conditionsObject



358
359
360
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 358

def having_conditions
  index_config["having"] || []
end

#import_csv_delimiterObject



526
527
528
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 526

def import_csv_delimiter
  import_config["csv_delimiter"] || ","
end

#import_csv_encodingObject



530
531
532
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 530

def import_csv_encoding
  import_config["csv_encoding"] || "auto"
end

#import_enabled?Boolean

— Import —

Returns:

  • (Boolean)


510
511
512
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 510

def import_enabled?
  import_config.present?
end

#import_formatsObject



514
515
516
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 514

def import_formats
  import_config["formats"] || [ "csv" ]
end

#import_max_file_sizeObject



522
523
524
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 522

def import_max_file_size
  import_config["max_file_size"] || 10_485_760 # 10 MiB
end

#import_max_rowsObject



518
519
520
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 518

def import_max_rows
  import_config["max_rows"] || 10_000
end

#import_nested_associationsObject



542
543
544
545
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 542

def import_nested_associations
  value = import_config["nested_associations"]
  value.is_a?(Array) ? value.map(&:to_s) : nil
end

#import_nested_blank_strategyObject



538
539
540
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 538

def import_nested_blank_strategy
  import_config["nested_blank_strategy"] || "null"
end

#import_parsingObject



534
535
536
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 534

def import_parsing
  import_config["parsing"] || {}
end

#index_layoutObject



371
372
373
374
375
376
377
378
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 371

def index_layout
  explicit = index_config["layout"]
  return explicit.to_sym if explicit

  return :grouped if grouped_query?
  return :tree if index_config["tree_view"] == true
  :table
end

#index_render_withObject



476
477
478
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 476

def index_render_with
  index_config["render_with"]
end

#item_classesObject



472
473
474
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 472

def item_classes
  @item_classes ||= index_config["item_classes"] || []
end

#kanban?Boolean

Returns:

  • (Boolean)


392
393
394
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 392

def kanban?
  index_layout == :kanban
end

#kanban_configObject



410
411
412
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 410

def kanban_config
  index_config["kanban"] || {}
end

#max_inline_actionsObject



547
548
549
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 547

def max_inline_actions
  (options["max_inline_actions"] || 3).to_i
end

#pagination_ends?Boolean

Returns:

  • (Boolean)


444
445
446
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 444

def pagination_ends?
  index_config.fetch("pagination_ends", LcpRuby.configuration.pagination_ends)
end

#per_pageObject



298
299
300
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 298

def per_page
  index_config["per_page"] || 25
end

#per_page_optionsObject



436
437
438
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 436

def per_page_options
  index_config["per_page_options"]
end

#read_only?Boolean

Returns:

  • (Boolean)


262
263
264
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 262

def read_only?
  options["read_only"] == true
end

#reorderable?Boolean

Returns:

  • (Boolean)


282
283
284
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 282

def reorderable?
  index_config["reorderable"] == true
end

#reparentable?Boolean

Returns:

  • (Boolean)


460
461
462
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 460

def reparentable?
  index_config["reparentable"] == true
end

#resolved_labelObject

Returns the presenter label resolved via i18n. Lookup: lcp_ruby.models.<model>.other, fallback to YAML label.



98
99
100
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 98

def resolved_label
  I18n.t("lcp_ruby.models.#{model}.other", default: @label)
end

#routable?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 102

def routable?
  slug.present?
end

#saved_filters_configObject



468
469
470
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 468

def saved_filters_config
  advanced_filter_config["saved_filters"] || {}
end

#saved_filters_enabled?Boolean

Returns:

  • (Boolean)


464
465
466
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 464

def saved_filters_enabled?
  advanced_filter_config.dig("saved_filters", "enabled") == true
end

#scopeObject



330
331
332
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 330

def scope
  raw_hash&.dig("scope")
end

#search_parametersObject



334
335
336
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 334

def search_parameters
  @search_parameters ||= (search_config["parameters"] || []).map { |h| Search::ParameterDefinition.from_hash(h) }
end

#show_record_count?Boolean

Returns:

  • (Boolean)


440
441
442
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 440

def show_record_count?
  index_config.fetch("show_record_count", true)
end

#show_render_withObject



480
481
482
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 480

def show_render_with
  show_config["render_with"]
end

#single_actionsObject



310
311
312
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 310

def single_actions
  @single_actions ||= derive_single_actions
end

#sort_fieldsObject



414
415
416
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 414

def sort_fields
  index_config["sort_fields"] || []
end

#source_location_for(attribute) ⇒ Object

i18n_check Phase 3a façade — see docs/design/i18n_consistency_check.md §B “Façade method signatures”. Each iterator yields a single keyword-arg hash including a ‘source:` key (nil for YAML-loaded presenters; Pass 3 of the lint covers the YAML path). All iterators read from the `@raw_*_config` hashes which preserve `_*_source_loc` keys; the public `*_config` accessors are sanitized for backward compat with tests that compare DSL-loaded vs YAML-loaded definitions structurally.



121
122
123
124
125
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 121

def source_location_for(attribute)
  case attribute
  when :label then @label_source_loc
  end
end

#summary_configObject



448
449
450
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 448

def summary_config
  index_config["summary"] || {}
end

#summary_enabled?Boolean

Returns:

  • (Boolean)


452
453
454
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 452

def summary_enabled?
  summary_config["enabled"] == true
end

#table_columnsObject



302
303
304
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 302

def table_columns
  index_config["table_columns"] || []
end

#tile_configObject



406
407
408
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 406

def tile_config
  index_config["tile"] || {}
end

#tiles?Boolean

Returns:

  • (Boolean)


388
389
390
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 388

def tiles?
  index_layout == :tiles
end

#tree_view?Boolean

Returns:

  • (Boolean)


380
381
382
# File 'lib/lcp_ruby/metadata/presenter_definition.rb', line 380

def tree_view?
  index_layout == :tree
end