Module: Trackerific::Services
- Defined in:
- lib/trackerific/services.rb
Defined Under Namespace
Modules: Concerns Classes: Base, FedEx, MockService, UPS, USPS
Class Method Summary collapse
-
.[](name) ⇒ Object
Finds a service by the given name.
-
.[]=(name, _class) ⇒ Object
Registers a service by the given name and class.
-
.find_by_package_id(id) ⇒ Array, Trackerific::Services::Base
Finds the tracking service(s) that are capable of tracking the given package ID capable of tracking the given ID.
Class Method Details
.[](name) ⇒ Object
Finds a service by the given name
10 11 12 |
# File 'lib/trackerific/services.rb', line 10 def [](name) @services[name] end |
.[]=(name, _class) ⇒ Object
Registers a service by the given name and class
18 19 20 21 22 23 24 25 26 |
# File 'lib/trackerific/services.rb', line 18 def []=(name, _class) unless _class.superclass == Trackerific::Services::Base raise ArgumentError, "Expected a Trackerific::Services::Base, got #{_class.inspect}", caller end @services[name] = _class end |
.find_by_package_id(id) ⇒ Array, Trackerific::Services::Base
Finds the tracking service(s) that are capable of tracking the given package ID capable of tracking the given ID.
36 37 38 |
# File 'lib/trackerific/services.rb', line 36 def find_by_package_id(id) @services.map {|n,s| s if s.can_track?(id) }.compact end |