module Mixture::Extensions
All of the extensions of mixture. Handles registration of extensions, so that extensions can be referend by a name instead of the constant.
Public Class Methods
Loads an extension with the given name. If it cannot find the matching extension, it raises a `KeyError`.
@param name [Symbol] The name of the extension. @return [Module] The corresponding extension. @raise [KeyError]
# File lib/mixture/extensions.rb, line 30 def self.[](name) extensions.fetch(name) end
The extensions that are registered with this module.
@return [Hash{Symbol => Module}]
# File lib/mixture/extensions.rb, line 37 def self.extensions @_extensions ||= {} end
Finalizes the extension module. It registers the extensions in Mixture
.
@return [void]
# File lib/mixture/extensions.rb, line 45 def self.finalize register :attribute, Attributable register :coerce, Coercable register :hash, Hashable register :validate, Validatable end
Registers an extension with the module. This maps a name to an extension. Extensions
may be registered multiple times, with different names.
@param name [Symbol] The name of the extension to register. @param extension [Module] The module to register.
# File lib/mixture/extensions.rb, line 20 def self.register(name, extension) extensions[name.to_s.downcase.intern] = extension end