Class: Vial::Registry
- Inherits:
-
Object
- Object
- Vial::Registry
- Defined in:
- lib/vial/registry.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #define(name, **options, &block) ⇒ Object
- #definitions ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 8 |
# File 'lib/vial/registry.rb', line 5 def initialize @definitions = [] @by_name = {} end |
Instance Method Details
#[](name) ⇒ Object
22 23 24 |
# File 'lib/vial/registry.rb', line 22 def [](name) @by_name[name.to_s] end |
#define(name, **options, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/vial/registry.rb', line 10 def define(name, **, &block) definition = Definition.new(name, **) definition.instance_eval(&block) if block @definitions << definition @by_name[definition.name] = definition definition end |
#definitions ⇒ Object
18 19 20 |
# File 'lib/vial/registry.rb', line 18 def definitions @definitions.dup end |