Class: Baha::ContainerOptions::Option
- Inherits:
-
Object
- Object
- Baha::ContainerOptions::Option
- Defined in:
- lib/baha/container_options/option.rb
Direct Known Subclasses
Constant Summary collapse
- KEYS =
{ :cmd => 'Cmd', :cpushares => 'CpuShares', :cpuset => 'Cpuset', :domainname => 'Domainname', :entrypoint => 'Entrypoint', :env => 'Env', :exposedports => 'ExposedPorts', :hostname => 'Hostname', :image => 'Image', :memory => 'Memory', :memoryswap => 'MemorySwap', :networkdisabled => 'NetworkDisabled', :user => 'User', :volumes => 'Volumes', :workingdir => 'WorkingDir', }
Instance Attribute Summary collapse
-
#config_key ⇒ Object
readonly
Returns the value of attribute config_key.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#apply(config) ⇒ Object
Apply this option to the container’s config hash.
- #eql?(other) ⇒ Boolean
-
#initialize(*args) ⇒ Option
constructor
A new instance of Option.
- #inspect ⇒ Object
-
#validate! ⇒ Object
Validate the option’s value.
Constructor Details
#initialize(*args) ⇒ Option
Returns a new instance of Option.
27 28 29 30 31 32 33 |
# File 'lib/baha/container_options/option.rb', line 27 def initialize(*args) k,@value = args raise ArgumentError, "Cannot understand option key '#{k}'" unless k.respond_to?(:to_sym) @key = k.to_sym.downcase raise ERROR("Option with key '#{@key}' is not found. Expecting #{KEYS.keys.inspect}") unless KEYS.has_key?(@key) @config_key = KEYS[@key] end |
Instance Attribute Details
#config_key ⇒ Object (readonly)
Returns the value of attribute config_key.
24 25 26 |
# File 'lib/baha/container_options/option.rb', line 24 def config_key @config_key end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
23 24 25 |
# File 'lib/baha/container_options/option.rb', line 23 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
25 26 27 |
# File 'lib/baha/container_options/option.rb', line 25 def value @value end |
Instance Method Details
#apply(config) ⇒ Object
Apply this option to the container’s config hash
40 41 42 |
# File 'lib/baha/container_options/option.rb', line 40 def apply(config) config[@config_key] = @value end |
#eql?(other) ⇒ Boolean
35 36 37 |
# File 'lib/baha/container_options/option.rb', line 35 def eql?(other) @key == other.key and @value == other.value end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/baha/container_options/option.rb', line 49 def inspect "#{self.class.name}<@key=#{@key.inspect},@value=#{@value.inspect}>" end |
#validate! ⇒ Object
Validate the option’s value
45 46 47 |
# File 'lib/baha/container_options/option.rb', line 45 def validate! KEYS.has_key?(@key) end |