Class: Indocker::Envs::EnvMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/indocker/envs/env_metadata.rb

Instance Method Summary collapse

Constructor Details

#initialize(variables = {}) ⇒ EnvMetadata

Returns a new instance of EnvMetadata.



3
4
5
# File 'lib/indocker/envs/env_metadata.rb', line 3

def initialize(variables = {})
  @variables = variables
end

Instance Method Details

#+(other) ⇒ Object



29
30
31
32
33
# File 'lib/indocker/envs/env_metadata.rb', line 29

def +(other)
  combined_hash = to_hash.merge(other.to_hash)

  Indocker::Envs::EnvMetadata.new(combined_hash)
end

#set(key:, value:) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/indocker/envs/env_metadata.rb', line 21

def set(key:, value:)
  overwritten = @variables.has_key?(key) and @variables[key] != value

  @variables[key] = value

  overwritten
end

#to_array ⇒ Object



15
16
17
18
19
# File 'lib/indocker/envs/env_metadata.rb', line 15

def to_array
  to_hash.inject([]) do |all, (k, v)|
    all.push "#{k}=#{v}"
  end
end

#to_hash ⇒ Object



7
8
9
# File 'lib/indocker/envs/env_metadata.rb', line 7

def to_hash
  @variables
end

#to_json ⇒ Object



11
12
13
# File 'lib/indocker/envs/env_metadata.rb', line 11

def to_json
  to_hash.to_json
end