Class: CommandDeck::BasePanel

Inherits:
Object
  • Object
show all
Defined in:
lib/command_deck/base_panel.rb

Overview

Base class for panel definitions.

Panels can be defined anywhere under a command_deck directory. The gem will auto-discover panels in:

- app/command_deck/**/*.rb
- packs/**/command_deck/**/*.rb

Use descriptive namespaces that match your project structure.

Example in app/command_deck/panels/global.rb:

module CommandDeck::Panels
  class Global < CommandDeck::BasePanel
    panel "Global Tools" do
      tab "Update" do
        action "Do Something", key: "global.do_something" do
          perform { |params, ctx| { ok: true } }
        end
      end
    end
  end
end

Class Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object



41
42
43
44
# File 'lib/command_deck/base_panel.rb', line 41

def inherited(subclass)
  super
  CommandDeck.register_panel_class(subclass)
end

.panel(title, **opts, &block) ⇒ Object



27
28
29
# File 'lib/command_deck/base_panel.rb', line 27

def panel(title, **opts, &block)
  @panel_definition = { title: title, opts: opts, block: block }
end

.register!Object



31
32
33
34
35
36
37
38
39
# File 'lib/command_deck/base_panel.rb', line 31

def register!
  return unless @panel_definition

  Registry.panel(
    @panel_definition[:title],
    **@panel_definition[:opts],
    &@panel_definition[:block]
  )
end