Class: AWS::Core::OptionGrammar::DefaultOption

Inherits:
Object
  • Object
show all
Includes:
AWS::Core::OptionGrammar::Descriptors::String
Defined in:
lib/aws/core/option_grammar.rb,
lib/aws/core/option_grammar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AWS::Core::OptionGrammar::Descriptors::String

#validate

Methods included from AWS::Core::OptionGrammar::Descriptors::NoArgs

#apply

Constructor Details

#initialize(name) ⇒ DefaultOption

Returns a new instance of DefaultOption.



438
439
440
# File 'lib/aws/core/option_grammar.rb', line 438

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



436
437
438
# File 'lib/aws/core/option_grammar.rb', line 436

def name
  @name
end

Instance Method Details

#context_description(context) ⇒ Object



472
473
474
# File 'lib/aws/core/option_grammar.rb', line 472

def context_description(context)
  context or "option #{ruby_name}"
end

#encode_value(value) ⇒ Object



459
460
461
# File 'lib/aws/core/option_grammar.rb', line 459

def encode_value(value)
  value
end

#extend_with_config(*descriptors) ⇒ Object



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/aws/core/option_grammar.rb', line 476

def extend_with_config(*descriptors)
  option = clone
  descriptors.each do |desc|
    if desc.kind_of?(Hash)
      (name, arg) = desc.to_a.first
      next if name == :documentation
    else
      name = desc
      arg = nil
    end
    class_name = Inflection.class_name(name.to_s)
    mod = Descriptors::const_get(class_name)
    if arg
      mod.apply(option, arg)
    else
      mod.apply(option)
    end
  end
  option
end

#format_error(expected, context = nil) ⇒ Object



467
468
469
470
# File 'lib/aws/core/option_grammar.rb', line 467

def format_error(expected, context = nil)
  context = context_description(context)
  FormatError.new(expected, context)
end

#hash_format(value) ⇒ Object



450
451
452
# File 'lib/aws/core/option_grammar.rb', line 450

def hash_format(value)
  value
end

#prefixed_name(prefix) ⇒ Object



454
455
456
457
# File 'lib/aws/core/option_grammar.rb', line 454

def prefixed_name(prefix)
  return "#{prefix}.#{name}" if prefix
  name
end

#request_params(value, prefix = nil) ⇒ Object



446
447
448
# File 'lib/aws/core/option_grammar.rb', line 446

def request_params(value, prefix = nil)
  [Http::Request::Param.new(prefixed_name(prefix), encode_value(value))]
end

#required?Boolean

Returns:

  • (Boolean)


463
464
465
# File 'lib/aws/core/option_grammar.rb', line 463

def required?
  false
end

#ruby_nameObject



442
443
444
# File 'lib/aws/core/option_grammar.rb', line 442

def ruby_name
  Inflection.ruby_name(name)
end