Class: Superhosting::Cli::Cmd::ModelTree

Inherits:
Base
  • Object
show all
Defined in:
lib/superhosting/cli/cmd/model_tree.rb

Constant Summary

Constants inherited from Base

Base::COMMANDS_MODULE, Base::CONTROLLERS_MODULE, Base::CONTROLLER_BASE_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#action, #clear_args, #get_childs_banners, get_cmd_and_node, #get_commands, #get_controller, #get_method, get_splited_class_name, #get_subcontroller_option, #help, #initialize, #positional_arguments, prepend, #run, set_banners, set_commands_hierarchy, split_toggle_case_name, start

Methods included from Helper::I18n

#i18n_initialize

Methods included from Helper::Logger

#__debug, #__dry_run, #__dry_run=, #__logger, #__logger=, #debug, #debug_block, #debug_operation, #indent, #indent=, #indent_reset, #indent_step, #indent_step_back, #info, #storage, #t, #with_dry_run, #with_indent, #with_logger

Constructor Details

This class inherits a constructor from Superhosting::Cli::Base

Class Method Details

.after_action(data, config) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/superhosting/cli/cmd/model_tree.rb', line 10

def after_action(data, config)
  def show_tree(node, type='model')
    node.each do |k, hash|
      self.info("#{"#{type}: " if type == 'mux'}#{k.name}")
      self.indent_step
      %w(mux model).each do |type|
        (hash[type] || []).each {|v| show_tree(v, type) } if !hash[type].nil? and !hash[type].empty?
      end
      self.indent_step_back
    end
  end

  old = self.indent
  show_tree(data)
  self.indent = old
end

.has_required_param?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/superhosting/cli/cmd/model_tree.rb', line 6

def has_required_param?
  true
end

Instance Method Details

#show_tree(node, type = 'model') ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/superhosting/cli/cmd/model_tree.rb', line 11

def show_tree(node, type='model')
  node.each do |k, hash|
    self.info("#{"#{type}: " if type == 'mux'}#{k.name}")
    self.indent_step
    %w(mux model).each do |type|
      (hash[type] || []).each {|v| show_tree(v, type) } if !hash[type].nil? and !hash[type].empty?
    end
    self.indent_step_back
  end
end