Module: Middleman::CoreExtensions::Extensions::ClassMethods

Defined in:
lib/middleman-core/core_extensions/extensions.rb

Overview

Class methods

Instance Method Summary collapse

Instance Method Details

#configure(env, &block) ⇒ void

This method returns an undefined value.

Add a callback to run in a specific environment

Parameters:

  • env (String, Symbol)

    The environment to run in



67
68
69
# File 'lib/middleman-core/core_extensions/extensions.rb', line 67

def configure(env, &block)
  send("#{env}_config", &block)
end

#extensionsArray<Module>

Alias ‘extensions` to access registered extensions

Returns:

  • (Array<Module>)


74
75
76
# File 'lib/middleman-core/core_extensions/extensions.rb', line 74

def extensions
  @extensions ||= []
end

#register(extension, options = {}, &block) ⇒ void

This method returns an undefined value.

Register a new extension

Parameters:

  • extension (Module)

    Extension modules to register

  • options (Hash) (defaults to: {})

    Per-extension options hash



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/middleman-core/core_extensions/extensions.rb', line 83

def register(extension, options={}, &block)
  @extensions ||= []
  @extensions += [extension]

  extend extension
  if extension.respond_to?(:registered)
    if extension.method(:registered).arity === 1
      extension.registered(self, &block)
    else
      extension.registered(self, options, &block)
    end
  end
end