Class: HammerCLIForeman::CommandExtensions::Hosts::Help::ComputeResources
- Inherits:
-
HammerCLI::CommandExtensions
- Object
- HammerCLI::CommandExtensions
- HammerCLIForeman::CommandExtensions::Hosts::Help::ComputeResources
- Defined in:
- lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb
Class Attribute Summary collapse
-
.add_host_specific_attrs ⇒ Object
writeonly
Sets the attribute add_host_specific_attrs.
- .attributes ⇒ Object
- .current_providers ⇒ Object
Class Method Summary collapse
- .add_host_specific_attrs? ⇒ Boolean
- .custom(options = {}) ⇒ Object
- .customized=(boolean) ⇒ Object
- .customized? ⇒ Boolean
- .help_block ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ComputeResources
constructor
A new instance of ComputeResources.
Constructor Details
#initialize(options = {}) ⇒ ComputeResources
Returns a new instance of ComputeResources.
78 79 80 81 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 78 def initialize( = {}) super self.class.class_eval(&self.class.help_block) unless self.class.customized? end |
Class Attribute Details
.add_host_specific_attrs=(value) ⇒ Object (writeonly)
Sets the attribute add_host_specific_attrs
7 8 9 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 7 def add_host_specific_attrs=(value) @add_host_specific_attrs = value end |
.attributes ⇒ Object
20 21 22 23 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 20 def attributes @attributes ||= :all @attributes end |
.current_providers ⇒ Object
10 11 12 13 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 10 def current_providers @current_providers ||= HammerCLIForeman.compute_resources.keys @current_providers end |
Class Method Details
.add_host_specific_attrs? ⇒ Boolean
15 16 17 18 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 15 def add_host_specific_attrs? @add_host_specific_attrs ||= false @add_host_specific_attrs end |
.custom(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 33 def custom( = {}) new_self = Class.new(ComputeResources) new_self.add_host_specific_attrs = [:add_host_specific_attrs] new_self.attributes = [:attributes] new_self.current_providers = [:providers] new_self.class_eval(&help_block) new_self.customized = true new_self end |
.customized=(boolean) ⇒ Object
29 30 31 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 29 def customized=(boolean) @customized ||= boolean end |
.customized? ⇒ Boolean
25 26 27 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 25 def customized? @customized end |
.help_block ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb', line 43 def help_block @help_block ||= Proc.new do help do |h| h.section(_('Provider specific options')) do |h| h.note(_('Bold attributes are required.'), richtext: true) HammerCLIForeman.compute_resources.each do |name, provider| next unless current_providers.include?(name) h.section(provider.name, id: name.to_sym) do |h| compute_attributes = provider.compute_attributes compute_attributes += provider.host_attributes if add_host_specific_attrs? if %i[all volume].include?(attributes) h.section('--volume') do |h| h.list(provider.volume_attributes) end end if %i[all interface].include?(attributes) h.section('--interface') do |h| h.list(provider.interface_attributes) end end if %i[all compute].include?(attributes) h.section('--compute-attributes', id: :s_compute_attributes) do |h| h.list(compute_attributes, id: :l_compute_attributes) end end end provider.extend_help(h) if provider.respond_to?(:extend_help) end end end end end |