Module: Mixture::Extensions
- Defined in:
- lib/mixture/extensions.rb,
lib/mixture/extensions/hashable.rb,
lib/mixture/extensions/coercable.rb,
lib/mixture/extensions/validatable.rb,
lib/mixture/extensions/attributable.rb
Overview
All of the extensions of mixture. Handles registration of extensions, so that extensions can be referend by a name instead of the constant.
Defined Under Namespace
Modules: Attributable, Coercable, Hashable, Validatable
Class Method Summary collapse
-
.[](name) ⇒ Module
Loads an extension with the given name.
-
.extensions ⇒ Hash{Symbol => Module}
The extensions that are registered with this module.
-
.finalize ⇒ void
Finalizes the extension module.
-
.register(name, extension) ⇒ Object
Registers an extension with the module.
Class Method Details
.[](name) ⇒ Module
Loads an extension with the given name. If it cannot find the
matching extension, it raises a KeyError
.
30 31 32 |
# File 'lib/mixture/extensions.rb', line 30 def self.[](name) extensions.fetch(name) end |
.extensions ⇒ Hash{Symbol => Module}
The extensions that are registered with this module.
37 38 39 |
# File 'lib/mixture/extensions.rb', line 37 def self.extensions @_extensions ||= {} end |
.finalize ⇒ void
This method returns an undefined value.
Finalizes the extension module. It registers the extensions in Mixture.
45 46 47 48 49 50 |
# File 'lib/mixture/extensions.rb', line 45 def self.finalize register :attribute, Attributable register :coerce, Coercable register :hash, Hashable register :validate, Validatable end |
.register(name, extension) ⇒ Object
Registers an extension with the module. This maps a name to an extension. Extensions may be registered multiple times, with different names.
20 21 22 |
# File 'lib/mixture/extensions.rb', line 20 def self.register(name, extension) extensions[name.to_s.downcase.intern] = extension end |