Module: Middleman::Configuration::Global

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

Overview

Access to a global configuration manager for the whole Middleman project, plus backwards compatibility mechanisms for older Middleman projects.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

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.



74
75
76
77
78
79
80
# File 'lib/middleman-core/configuration.rb', line 74

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

Class Method Details

.included(app) ⇒ Object



6
7
8
# File 'lib/middleman-core/configuration.rb', line 6

def self.included(app)
  app.send :extend, ClassMethods
end

Instance Method Details

#configObject Also known as: settings



47
48
49
# File 'lib/middleman-core/configuration.rb', line 47

def config
  self.class.config
end

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

Needed so that method_missing makes sense

Returns:

  • (Boolean)


83
84
85
# File 'lib/middleman-core/configuration.rb', line 83

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

#set(key, value = 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

  • value (defaults to: nil)

    Attribute value



65
66
67
68
# File 'lib/middleman-core/configuration.rb', line 65

def set(key, value=nil, &block)
  value = block if block_given?
  config[key] = value
end