Module: WSList
- Defined in:
- lib/ws_list.rb
Overview
Wrapper module to keep track of all defined services
Defined Under Namespace
Classes: UnknownService
Class Method Summary collapse
-
.[](url) ⇒ Nil, WSDSL
Returns a service based on its url.
-
.add(service) ⇒ Array<WSDSL>
Add a service to the array tracking the playco services.
-
.all ⇒ Array<WSDSL>
Returns an array of services.
-
.named(name) ⇒ WSDSL
Returns a service based on its name.
Class Method Details
.[](url) ⇒ Nil, WSDSL
Returns a service based on its url
52 53 54 |
# File 'lib/ws_list.rb', line 52 def [](url) @list.find{|service| service.url == url} end |
.add(service) ⇒ Array<WSDSL>
Add a service to the array tracking the playco services
16 17 18 19 20 |
# File 'lib/ws_list.rb', line 16 def add(service) @list ||= [] @list << service unless @list.find{|s| s.url == service.url && s.verb == service.verb} @list end |
.all ⇒ Array<WSDSL>
Returns an array of services
26 27 28 |
# File 'lib/ws_list.rb', line 26 def all @list || [] end |
.named(name) ⇒ WSDSL
Returns a service based on its name
37 38 39 40 41 42 43 44 |
# File 'lib/ws_list.rb', line 37 def named(name) service = all.find{|service| service.name == name} if service.nil? raise UnknownService, "Service named #{name} isn't available" else service end end |