lib/hexx/service.rb in hexx-5.2.0 vs lib/hexx/service.rb in hexx-5.3.0
- old
+ new
@@ -88,15 +88,13 @@
# @param [Hash] options The list of the subscription options.
# @option options [Symbol] :prefix The prefix for the listener's callbacks.
# @abstract
# Runs the service object.
- # @note The method must be reloaded by a specific service class,
- # inherited from <tt>Hexx::Service</tt>.
- # @raise [NotImplementedError] if a child class hasn't redefined the method.
+ # @note The method does nothing and should be reloaded by a specific
+ # service class.
def run
- fail NotImplementedError.new "#{ self.class.name }#run not implemented."
end
# Makes private methods with given prefix public.
#
# @example Opens private methods.
@@ -169,17 +167,15 @@
# def on_item_not_found(*)
# # ... do some stuff here
# end
# end
#
- # @param [Class] service_class The service class to instantiate and run
- # a service object.
+ # @param [Hexx::Service] service_class The class for the service object to
+ # run.
# @param [Symbol] prefix The prefix for callbacks to receive the service
# object's notifications.
# @param [Hash] options ({}) The options for the service object initializer.
- # @raise [TypeError] when the service_class is not a <tt>Hexx::Service</tt>.
def run_service(service_class, prefix, options = {})
- fail TypeError unless service_class.ancestors.include? Hexx::Service
service = service_class.new(options)
service.subscribe with_callbacks, prefix: prefix
service.run
end