Class: MotherBrain::Cli::SubCommand::Component Private
- Extended by:
- Forwardable
- Defined in:
- lib/mb/cli/sub_command/component.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A set of component tasks collected into a SubCommand to be registered with the CliGateway. This class should not be instantiated, configured, and used by itself. Use Component.fabricate to create an anonymous class of this type.
Class Attribute Summary collapse
-
.component ⇒ MB::Component
readonly
private
Return the component associated with this instance of the class.
Class Method Summary collapse
- .fabricate(component) ⇒ SubCommand::Component private
-
.set_component(component) ⇒ Object
private
Set the component for this instance of the class and tailor the class for the given component.
Methods inherited from Base
define_task, description, usage
Methods inherited from Base
Class Attribute Details
.component ⇒ MB::Component (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the component associated with this instance of the class
18 19 20 |
# File 'lib/mb/cli/sub_command/component.rb', line 18 def component @component end |
Class Method Details
.fabricate(component) ⇒ SubCommand::Component
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mb/cli/sub_command/component.rb', line 23 def fabricate(component) environment = CliGateway.invoked_opts[:environment] Class.new(self) do set_component(component) component.commands.each do |command| define_task(command) end desc("nodes", "List all nodes grouped by Group") define_method(:nodes) do ui.say "Listing nodes for '#{component.name}' in '#{environment}':" nodes = component.nodes(environment).each do |group, nodes| nodes.collect! { |node| "#{node.public_hostname} (#{node.public_ipv4})" } end ui.say nodes.to_yaml end end end |
.set_component(component) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the component for this instance of the class and tailor the class for the given component.
48 49 50 51 |
# File 'lib/mb/cli/sub_command/component.rb', line 48 def set_component(component) self.namespace(component.name) @component = component end |