Class: CommandDeck::Registry

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

Overview

Registry for actions and panels

Defined Under Namespace

Classes: Action, ActionBuilder, Panel, PanelBuilder, Tab, TabBuilder

Class Method Summary collapse

Class Method Details

.clear!Object



16
17
18
# File 'lib/command_deck/registry.rb', line 16

def clear!
  @panels = []
end

.find_action(key) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/command_deck/registry.rb', line 24

def find_action(key)
  panels.each do |p|
    p.tabs.each do |t|
      t.actions.each do |a|
        return a if a.key == key
      end
    end
  end
  nil
end

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



20
21
22
# File 'lib/command_deck/registry.rb', line 20

def panel(title, **opts, &blk)
  PanelBuilder.new(title, **opts).tap { |pb| pb.instance_eval(&blk) if blk }.build.then { panels << _1 }
end

.panelsObject



12
13
14
# File 'lib/command_deck/registry.rb', line 12

def panels
  @panels ||= []
end