Class: CommandDeck::Registry::ActionBuilder

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

Overview

Action builder

Instance Method Summary collapse

Constructor Details

#initialize(title, key) ⇒ ActionBuilder

Returns a new instance of ActionBuilder.



79
80
81
82
83
84
# File 'lib/command_deck/registry.rb', line 79

def initialize(title, key)
  @title  = title
  @key    = key
  @params = []
  @block  = nil
end

Instance Method Details

#buildObject



94
95
96
# File 'lib/command_deck/registry.rb', line 94

def build
  Action.new(title: @title, key: @key, params: @params, block: @block)
end

#param(name, type, **opts) ⇒ Object



86
87
88
# File 'lib/command_deck/registry.rb', line 86

def param(name, type, **opts)
  @params << { name: name, type: type, **opts }
end

#perform(&block) ⇒ Object



90
91
92
# File 'lib/command_deck/registry.rb', line 90

def perform(&block)
  @block = block
end