Class: Hyperb::HostConfig

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/hyperb/containers/host_config.rb

Overview

helper for managing creating proper container host configs

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#camelize, #check_arguments, #downcase_symbolize, #prepare_json, #underscore

Constructor Details

#initialize(params = {}) ⇒ HostConfig

Returns a new instance of HostConfig.



13
14
15
16
17
18
# File 'lib/hyperb/containers/host_config.rb', line 13

def initialize(params = {})
  params.each do |att, value|
    value = downcase_symbolize(value) if value.is_a?(Hash)
    instance_variable_set("@#{underscore(att)}", value)
  end
end

Instance Attribute Details

#bindsObject

Returns the value of attribute binds.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def binds
  @binds
end

Returns the value of attribute links.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def links
  @links
end

#log_configObject

Returns the value of attribute log_config.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def log_config
  @log_config
end

#network_modeObject

Returns the value of attribute network_mode.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def network_mode
  @network_mode
end

#port_bindingsObject

Returns the value of attribute port_bindings.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def port_bindings
  @port_bindings
end

#publish_all_portsObject

Returns the value of attribute publish_all_ports.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def publish_all_ports
  @publish_all_ports
end

#readonly_rootfsObject

Returns the value of attribute readonly_rootfs.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def readonly_rootfs
  @readonly_rootfs
end

#restart_policyObject

Returns the value of attribute restart_policy.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def restart_policy
  @restart_policy
end

#volume_driverObject

Returns the value of attribute volume_driver.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def volume_driver
  @volume_driver
end

#volumes_fromObject

Returns the value of attribute volumes_from.



9
10
11
# File 'lib/hyperb/containers/host_config.rb', line 9

def volumes_from
  @volumes_from
end

Instance Method Details

#attrsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/hyperb/containers/host_config.rb', line 31

def attrs
  {
    binds: binds,
    links: links,
    port_bindings: port_bindings,
    publish_all_ports: publish_all_ports,
    network_mode: network_mode,
    restart_policy: restart_policy,
    volume_driver: volume_driver,
    log_config: log_config,
    readonly_rootfs: readonly_rootfs,
    volumes_from: volumes_from
  }
end

#fmtObject

returns a hash containing formated host config data



23
24
25
26
27
28
29
# File 'lib/hyperb/containers/host_config.rb', line 23

def fmt
  formated = {}
  attrs.keys.each do |key|
    formated[camelize(key)] = attrs[key]
  end
  formated
end