Class: Docks::Builder::Config

Inherits:
Mustache
  • Object
show all
Defined in:
lib/docks/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Config

Returns a new instance of Config.



10
11
12
# File 'lib/docks/build.rb', line 10

def initialize(options)
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/docks/build.rb', line 20

def method_missing(meth)
  if options.respond_to?(meth)
    present(options.send(meth), meth)
  elsif !(result = default_config.instance_variable_get("@#{meth}".to_sym)).nil?
    present(result, meth)
  else
    super
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/docks/build.rb', line 8

def options
  @options
end

Instance Method Details

#default_configObject



14
# File 'lib/docks/build.rb', line 14

def default_config; @default_config ||= Docks.config end

#respond_to?(meth) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/docks/build.rb', line 16

def respond_to?(meth)
  options.respond_to?(meth) || !default_config.instance_variable_get("@#{meth}".to_sym).nil? || super
end