Class: Quickl::Command::Builder
Instance Method Summary collapse
-
#class_modules(*mods) ⇒ Object
(also: #class_module)
Adds some command class modules.
-
#document(file, line) ⇒ Object
Adds document tracking information.
-
#instance_modules(*mods) ⇒ Object
(also: #instance_module)
Adds some command instance modules.
-
#run(command) ⇒ Object
Installs on a command subclass.
Instance Method Details
#class_modules(*mods) ⇒ Object Also known as: class_module
Adds some command class modules
11 12 13 14 15 16 17 |
# File 'lib/quickl/command/builder.rb', line 11 def class_modules(*mods) @class_modules ||= [ Command::ClassMethods, Command::Options::ClassMethods, ] @class_modules += mods end |
#document(file, line) ⇒ Object
Adds document tracking information
6 7 8 |
# File 'lib/quickl/command/builder.rb', line 6 def document(file, line) @file, @line = file, line end |
#instance_modules(*mods) ⇒ Object Also known as: instance_module
Adds some command instance modules
21 22 23 24 25 26 27 28 |
# File 'lib/quickl/command/builder.rb', line 21 def instance_modules(*mods) @instance_modules ||= [ Command::InstanceMethods, Command::Robustness, Command::Options::InstanceMethods ] @instance_modules += mods end |
#run(command) ⇒ Object
Installs on a command subclass
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/quickl/command/builder.rb', line 32 def run(command) # install class and instance methods class_modules.each{|mod| command.extend(mod) } instance_modules.each{|mod| command.instance_eval{ include mod } } # install documentation if @file and @line command.doc_place = [@file, @line] end # install hierarchy parent = RubyTools::parent_module(command) if parent && parent.ancestors.include?(Command) command.super_command = parent parent.subcommands << command end command end |