Class: Indocker::BuildContextHelper::Containers

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

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Containers

Returns a new instance of Containers.



49
50
51
# File 'lib/indocker/build_context_helper.rb', line 49

def initialize(configuration)
  @configuration = configuration
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/indocker/build_context_helper.rb', line 53

def method_missing(name, *args)
  if args.size > 0
    raise ArgumentError.new("containers.#{name} does not accept arguments")
  end

  if Indocker.container_files.has_key?(name)
    require Indocker.container_files.fetch(name)
  end

  container = @configuration.containers.detect do |container|
    container.name == name
  end

  if !container
    raise ArgumentError.new("container :#{name} was not found in configuration")
  end

  Container.new(@configuration, container)
end