Class: Pfm::CommandsMap
- Inherits:
-
Object
- Object
- Pfm::CommandsMap
- Defined in:
- lib/iapi-idlc-sdk-pfm/commands_map.rb
Defined Under Namespace
Classes: CommandSpec
Constant Summary collapse
- NULL_ARG =
Object.new
Instance Attribute Summary collapse
-
#command_specs ⇒ Object
readonly
Returns the value of attribute command_specs.
Instance Method Summary collapse
- #builtin(name, constant_name, require_path: NULL_ARG, desc: "") ⇒ Object
- #command_names ⇒ Object
- #have_command?(name) ⇒ Boolean
-
#initialize ⇒ CommandsMap
constructor
A new instance of CommandsMap.
- #instantiate(name) ⇒ Object
- #spec_for(name) ⇒ Object
Constructor Details
#initialize ⇒ CommandsMap
Returns a new instance of CommandsMap.
19 20 21 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 19 def initialize @command_specs = {} end |
Instance Attribute Details
#command_specs ⇒ Object (readonly)
Returns the value of attribute command_specs.
17 18 19 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 17 def command_specs @command_specs end |
Instance Method Details
#builtin(name, constant_name, require_path: NULL_ARG, desc: "") ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 23 def builtin(name, constant_name, require_path: NULL_ARG, desc: "") if null?(require_path) snake_case_path = name.tr("-", "_") require_path = "iapi-idlc-sdk-pfm/command/#{snake_case_path}" end command_specs[name] = CommandSpec.new(name, constant_name, require_path, desc) end |
#command_names ⇒ Object
39 40 41 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 39 def command_names command_specs.keys end |
#have_command?(name) ⇒ Boolean
35 36 37 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 35 def have_command?(name) command_specs.key?(name) end |
#instantiate(name) ⇒ Object
31 32 33 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 31 def instantiate(name) spec_for(name).instantiate end |
#spec_for(name) ⇒ Object
43 44 45 |
# File 'lib/iapi-idlc-sdk-pfm/commands_map.rb', line 43 def spec_for(name) command_specs[name] end |