Module: Benry::CmdApp::ClassMethodModule
- Included in:
- Benry::CmdApp
- Defined in:
- lib/benry/cmdapp.rb
Instance Method Summary collapse
-
#_set_current_app(app) ⇒ Object
:nodoc:.
-
#current_app ⇒ Object
:nodoc:.
- #define_abbrev(abbrev, prefix) ⇒ Object
- #define_alias(alias_name, action_name, tag: nil, important: nil, hidden: nil) ⇒ Object
-
#define_alias!(alias_name, action_name, tag: nil, important: nil, hidden: nil) ⇒ Object
:nodoc:.
- #undef_action(action_name) ⇒ Object
- #undef_alias(alias_name) ⇒ Object
Instance Method Details
#_set_current_app(app) ⇒ Object
:nodoc:
484 485 486 487 488 |
# File 'lib/benry/cmdapp.rb', line 484 def _set_current_app(app) # :nodoc: #; [!1yqwl] sets current application. @current_app = app nil end |
#current_app ⇒ Object
:nodoc:
479 480 481 482 |
# File 'lib/benry/cmdapp.rb', line 479 def current_app() # :nodoc: #; [!xdjce] returns current application. return @current_app end |
#define_abbrev(abbrev, prefix) ⇒ Object
447 448 449 450 451 452 453 454 455 |
# File 'lib/benry/cmdapp.rb', line 447 def define_abbrev(abbrev, prefix) #; [!e1fob] raises DefinitionError if error found. errmsg = __validate_abbrev(abbrev, prefix) errmsg == nil or raise DefinitionError.new(errmsg) #; [!ed6hr] registers abbrev with prefix. REGISTRY.abbrev_add(abbrev, prefix) nil end |
#define_alias(alias_name, action_name, tag: nil, important: nil, hidden: nil) ⇒ Object
351 352 353 |
# File 'lib/benry/cmdapp.rb', line 351 def define_alias(alias_name, action_name, tag: nil, important: nil, hidden: nil) return __define_alias(alias_name, action_name, tag: tag, important: important, hidden: hidden, alias_for_alias: false) end |
#define_alias!(alias_name, action_name, tag: nil, important: nil, hidden: nil) ⇒ Object
:nodoc:
355 356 357 |
# File 'lib/benry/cmdapp.rb', line 355 def define_alias!(alias_name, action_name, tag: nil, important: nil, hidden: nil) # :nodoc: return __define_alias(alias_name, action_name, tag: tag, important: important, hidden: hidden, alias_for_alias: true) end |
#undef_action(action_name) ⇒ Object
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/benry/cmdapp.rb', line 426 def undef_action(action_name) #; [!bcyn3] raises DefinitionError if action name is not a string. Util.name_should_be_a_string(action_name, 'Action', DefinitionError) #; [!bvu95] raises error if action not exist. #; [!717fw] raises error if alias specified instead of action. md = REGISTRY.(action_name) errmsg = ( if md == nil ; "Action not exist." elsif md.alias? ; "Action expected but alias name specified." else ; nil end ) errmsg == nil or raise DefinitionError.new("undef_action(#{action_name.inspect}): #{errmsg}") #; [!01sx1] deletes existing action. REGISTRY.(action_name) #; [!op8z5] deletes action method from action class. md.klass.class_eval { remove_method(md.meth) } nil end |
#undef_alias(alias_name) ⇒ Object
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/benry/cmdapp.rb', line 407 def undef_alias(alias_name) #; [!pk3ya] raises DefinitionError if alias name is not a string. Util.name_should_be_a_string(alias_name, 'Alias', DefinitionError) #; [!krdkt] raises DefinitionError if alias not exist. #; [!juykx] raises DefinitionError if action specified instead of alias. md = REGISTRY.(alias_name) errmsg = ( if md == nil ; "Alias not exist." elsif md.alias? ; nil else ; "Alias expected but action name specified." end ) errmsg == nil or raise DefinitionError.new("undef_alias(#{alias_name.inspect}): #{errmsg}") #; [!ocyso] deletes existing alias. REGISTRY.(alias_name) nil end |