Module: Flatter::Extension::Registrar

Included in:
Flatter
Defined in:
lib/flatter/extension/registrar.rb

Constant Summary collapse

UnknownExtensionError =
Class.new(ArgumentError)

Instance Method Summary collapse

Instance Method Details

#extensionsObject



5
6
7
# File 'lib/flatter/extension/registrar.rb', line 5

def extensions
  @extensions ||= {}
end

#use(extension_name, **opts) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/flatter/extension/registrar.rb', line 9

def use(extension_name, **opts)
  require opts[:require] if opts[:require].present?

  extension = extensions[extension_name]

  fail UnknownExtensionError, "Unknown extension #{extension_name}" if extension.nil?

  extension.hook!
end