Class: HasHelpers::Cards::AvailableCardsCommand

Inherits:
Object
  • Object
show all
Defined in:
app/commands/has_helpers/cards/available_cards_command.rb

Overview

Command object that returns the catalog of cards available for a given resource WITHOUT resolving any record data. Unlike CardDataCommand this is global (not scoped to a role): it does not apply role visibility/position overrides and does not build field entries.

For each CardDefinition linked to the resource it returns the card-level metadata (name, description, identifier, layout, variant, position) plus the non-persisted presentation hints (icon_name, icon_color) which live in the DSL registry only.

Usage:

cards = HasHelpers::Cards::AvailableCardsCommand.call(resource_id: resource)
cards.first # => { id:, name:, description:, identifier:, layout:, variant:,
          #      position:, icon_name:, icon_color: }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource_id:) ⇒ AvailableCardsCommand

Returns a new instance of AvailableCardsCommand.



24
25
26
# File 'app/commands/has_helpers/cards/available_cards_command.rb', line 24

def initialize(resource_id:)
  @resource = find_resource(resource_id)
end

Class Method Details

.call(resource_id:) ⇒ Object



20
21
22
# File 'app/commands/has_helpers/cards/available_cards_command.rb', line 20

def self.call(resource_id:)
  new(resource_id: resource_id).call
end

Instance Method Details

#callObject



28
29
30
# File 'app/commands/has_helpers/cards/available_cards_command.rb', line 28

def call
  card_definitions.map { |card_definition| serialize_card(card_definition) }
end