Class: Gearhead::Registry
- Inherits:
-
Object
- Object
- Gearhead::Registry
- Defined in:
- lib/gearhead/registry.rb
Instance Method Summary collapse
- #all ⇒ Object
- #find(path) ⇒ Object
- #for_resource(resource) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #register(gear) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
3 4 5 6 |
# File 'lib/gearhead/registry.rb', line 3 def initialize @resource_map = {} @router = {} end |
Instance Method Details
#all ⇒ Object
22 23 24 |
# File 'lib/gearhead/registry.rb', line 22 def all @resource_map.values end |
#find(path) ⇒ Object
18 19 20 |
# File 'lib/gearhead/registry.rb', line 18 def find(path) @router[path] end |
#for_resource(resource) ⇒ Object
14 15 16 |
# File 'lib/gearhead/registry.rb', line 14 def for_resource(resource) @resource_map[resource] end |
#register(gear) ⇒ Object
8 9 10 11 12 |
# File 'lib/gearhead/registry.rb', line 8 def register(gear) @resource_map[gear.resource.name] = gear @router[gear.path] = gear true end |