Module: DockerBuilder::Config::Helpers

Defined in:
lib/docker_builder/config/helpers.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object (private)

Check missing methods for deprecated attribute accessors.

If a value is set on an accessor that has been deprecated using #attr_deprecate, a warning will be issued and any :action (Proc) specified will be called with a reference to the class instance and the value set on the deprecated accessor. See #attr_deprecate and #log_deprecation_warning

Note that OpenStruct (used for setting defaults) does not allow multiple arguments when assigning values for members. So, we won’t allow it here either, even though an attr_accessor will accept and convert them into an Array. Therefore, setting an option value using multiple values, whether as a default or directly on the class’ accessor, should not be supported. i.e. if an option will accept being set as an Array, then it should be explicitly set as such. e.g. option = [val1, val2]



71
72
73
74
75
76
77
78
79
80
# File 'lib/docker_builder/config/helpers.rb', line 71

def method_missing(name, *args)
  if method = name.to_s.chomp!('=')
    if (len = args.count) != 1
      raise ArgumentError,
            "wrong number of arguments (#{ len } for 1)", caller(1)
    end
  end

  super
end

Class Method Details

.included(klass) ⇒ Object



8
9
10
# File 'lib/docker_builder/config/helpers.rb', line 8

def self.included(klass)
  klass.extend ClassMethods
end