Method: Middleman::Extension.expose_to_application

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

.expose_to_application(*symbols)

This method returns an undefined value.

Takes a method within this extension and exposes it globally on the main app instance. Used for very low-level extensions which many other extensions depend upon. Such as Data and File watching.

Examples:

with Hash:

expose_to_application global_name: :local_name

with Array:

expose_to_application :method1, :method2

Parameters:

  • symbols (Array<Sumbol>, Hash<Symbol, Symbol>)

    An optional list of symbols representing instance methods to exposed.



208
209
210
211
212
213
214
215
216
217
218
# File 'lib/middleman-core/extension.rb', line 208

def expose_to_application(*symbols)
  self.exposed_to_application ||= {}

  if symbols.first && symbols.first.is_a?(Hash)
    self.exposed_to_application.merge!(symbols.first)
  elsif symbols.is_a? Array
    symbols.each do |sym|
      self.exposed_to_application[sym] = sym
    end
  end
end