Class: Irumugam::ServiceRegistry
- Inherits:
-
Object
- Object
- Irumugam::ServiceRegistry
- Includes:
- Singleton
- Defined in:
- lib/irumugam/service_registry.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#services ⇒ Object
Returns the value of attribute services.
Class Method Summary collapse
Instance Method Summary collapse
- #cleanup! ⇒ Object
- #find(request) ⇒ Object
-
#initialize ⇒ ServiceRegistry
constructor
A new instance of ServiceRegistry.
- #paths_for(service_name) ⇒ Object
Constructor Details
#initialize ⇒ ServiceRegistry
Returns a new instance of ServiceRegistry.
7 8 9 10 |
# File 'lib/irumugam/service_registry.rb', line 7 def initialize @paths ||= {} @services ||= {} end |
Instance Attribute Details
#paths ⇒ Object
Returns the value of attribute paths.
5 6 7 |
# File 'lib/irumugam/service_registry.rb', line 5 def paths @paths end |
#services ⇒ Object
Returns the value of attribute services.
5 6 7 |
# File 'lib/irumugam/service_registry.rb', line 5 def services @services end |
Class Method Details
.cleanup! ⇒ Object
26 27 28 |
# File 'lib/irumugam/service_registry.rb', line 26 def self.cleanup! instance.cleanup! end |
.desc(name, &block) ⇒ Object
30 31 32 |
# File 'lib/irumugam/service_registry.rb', line 30 def self.desc(name,&block) instance.services[name] = Service.new(name, block) end |
.find(request) ⇒ Object
34 35 36 |
# File 'lib/irumugam/service_registry.rb', line 34 def self.find(request) instance.find(request) end |
Instance Method Details
#cleanup! ⇒ Object
12 13 14 15 |
# File 'lib/irumugam/service_registry.rb', line 12 def cleanup! @paths = {} @services = {} end |
#find(request) ⇒ Object
17 18 19 20 |
# File 'lib/irumugam/service_registry.rb', line 17 def find(request) req_body = request.body.read paths.values.flatten.select { |c| c.matches?(request, req_body) }.first end |
#paths_for(service_name) ⇒ Object
22 23 24 |
# File 'lib/irumugam/service_registry.rb', line 22 def paths_for(service_name) paths.values.flatten.select { |c| c.service.name==service_name } end |