Module: Middleman::Configuration::Global::ClassMethods

Defined in:
lib/middleman-core/configuration.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object

Deprecated.

Prefer accessing settings through “config”.

Access global settings as methods, to preserve compatibility with old Middleman.



33
34
35
36
37
38
39
# File 'lib/middleman-core/configuration.rb', line 33

def method_missing(method, *args)
  if config.defines_setting? method
    config[method]
  else
    super
  end
end

Instance Method Details

#configConfigurationManager

Global configuration for the whole Middleman project.



13
14
15
# File 'lib/middleman-core/configuration.rb', line 13

def config
  @_config ||= ConfigurationManager.new
end

#respond_to?(method, include_private = false) ⇒ Boolean

Needed so that method_missing makes sense

Returns:

  • (Boolean)


42
43
44
# File 'lib/middleman-core/configuration.rb', line 42

def respond_to?(method, include_private = false)
  super || config.defines_setting?(method)
end

#set(key, default = nil, &block) ⇒ void

Deprecated.

Prefer accessing settings through “config”.

This method returns an undefined value.

Set attributes (global variables)

Parameters:

  • key (Symbol)

    Name of the attribue

  • default (defaults to: nil)

    Attribute value



24
25
26
27
# File 'lib/middleman-core/configuration.rb', line 24

def set(key, default=nil, &block)
  config.define_setting(key, default) unless config.defines_setting?(key)
  @inst.set(key, default, &block) if @inst
end