Class: LintTrap::Registry
- Inherits:
-
Object
- Object
- LintTrap::Registry
- Defined in:
- lib/lint_trap/registry.rb
Overview
Allow registration and discovery of plugins
Instance Method Summary collapse
- #all ⇒ Object
- #default(thing_class) ⇒ Object
- #find(name) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #register(thing_class) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
4 5 6 |
# File 'lib/lint_trap/registry.rb', line 4 def initialize @registry = {} end |
Instance Method Details
#all ⇒ Object
21 22 23 |
# File 'lib/lint_trap/registry.rb', line 21 def all registry.values end |
#default(thing_class) ⇒ Object
8 9 10 |
# File 'lib/lint_trap/registry.rb', line 8 def default(thing_class) @registry.default = thing_class.new end |
#find(name) ⇒ Object
17 18 19 |
# File 'lib/lint_trap/registry.rb', line 17 def find(name) registry[name] end |
#register(thing_class) ⇒ Object
12 13 14 15 |
# File 'lib/lint_trap/registry.rb', line 12 def register(thing_class) thing = thing_class.new registry[thing.name] = thing end |