Class: Indocker::ContextArgs

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, context_args, parent, container = nil) ⇒ ContextArgs

Returns a new instance of ContextArgs.



4
5
6
7
8
9
# File 'lib/indocker/context_args.rb', line 4

def initialize(name, context_args, parent, container = nil)
  @name = name
  @parent = parent
  @container = container
  @context_args = context_args
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/indocker/context_args.rb', line 11

def method_missing(name, *args)
  if args.size > 0
    raise ArgumentError.new("context args does not accept any arguments")
  end

  value = @context_args.fetch(name) do
    Indocker.logger.warn("build arg '#{format_arg(name)}' is not defined#{@container ? " for container :#{@container.name}" : ""}")
    Indocker.logger.warn("available args: #{@context_args.inspect}")

    nil
  end

  if value.is_a?(Hash)
    Indocker::ContextArgs.new(name, value, self, @container)
  else
    value
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/indocker/context_args.rb', line 2

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



2
3
4
# File 'lib/indocker/context_args.rb', line 2

def parent
  @parent
end