Module: DkComposer::Composefile::Service
- Included in:
- Service
- Defined in:
- lib/dkcomposer/dockercompose.rb
Constant Summary collapse
- KEYWORDS =
{ image: :string, environment: :hash, ports: :array, links: :array, depends_on: :array, healthcheck: :hash, command: :string, extra_hosts: :array, volumes: :array, networks: :array, version: :string, stdin_open: :string, privileged: :string, hostname: :string, domainname: :string, container_name: :string, cap_add: :array, tty: :string }.freeze
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *params, **opts, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dkcomposer/dockercompose.rb', line 24 def method_missing(method, *params, **opts, &block) if KEYWORDS.key?(method) @fields ||= {} case KEYWORDS[method] when :array @fields[method] = params.flatten when :hash @fields[method] = if params.empty? opts.stringfy_bool_value else params.map { |x| x.split('=') }.to_h.stringfy_bool_value end else v, = params @fields[method] = v end else super end end |