Class: Cranium::DefinitionRegistry
- Inherits:
-
Object
- Object
- Cranium::DefinitionRegistry
- Defined in:
- lib/cranium/definition_registry.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(definition_class) ⇒ DefinitionRegistry
constructor
A new instance of DefinitionRegistry.
- #register_definition(name, &block) ⇒ Object
Constructor Details
#initialize(definition_class) ⇒ DefinitionRegistry
Returns a new instance of DefinitionRegistry.
3 4 5 6 |
# File 'lib/cranium/definition_registry.rb', line 3 def initialize(definition_class) @definition_class = definition_class @definitions = {} end |
Instance Method Details
#[](name) ⇒ Object
10 11 12 |
# File 'lib/cranium/definition_registry.rb', line 10 def [](name) @definitions[name] end |
#register_definition(name, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/cranium/definition_registry.rb', line 16 def register_definition(name, &block) definition = @definition_class.new name definition.instance_eval &block @definitions[name] = definition end |