Class: HammerCLI::Apipie::OptionBuilder

Inherits:
HammerCLI::AbstractOptionBuilder show all
Defined in:
lib/hammer_cli/apipie/option_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, action, options = {}) ⇒ OptionBuilder

Returns a new instance of OptionBuilder.



6
7
8
9
10
# File 'lib/hammer_cli/apipie/option_builder.rb', line 6

def initialize(resource, action, options={})
  @action = action
  @resource = resource
  @require_options = options[:require_options].nil? ? true : options[:require_options]
end

Instance Attribute Details

#require_options=(value) ⇒ Object (writeonly)

Sets the attribute require_options

Parameters:

  • value

    the value to set the attribute require_options to.



19
20
21
# File 'lib/hammer_cli/apipie/option_builder.rb', line 19

def require_options=(value)
  @require_options = value
end

Instance Method Details

#build(builder_params = {}) ⇒ Object



12
13
14
15
16
17
# File 'lib/hammer_cli/apipie/option_builder.rb', line 12

def build(builder_params = {})
  filter = Array(builder_params[:without])
  resource_name_map = builder_params[:resource_mapping] || {}

  options_for_params(@action.params, filter, resource_name_map, command: builder_params[:command])
end

#require_options?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/hammer_cli/apipie/option_builder.rb', line 20

def require_options?
  @require_options
end