Class: Inflect::Director

Inherits:
Object
  • Object
show all
Includes:
ServiceProviderMethods
Defined in:
lib/inflect/director.rb

Overview

The class in charge of managing the access and selection of the services.

Instance Method Summary collapse

Methods included from ServiceProviderMethods

included

Instance Method Details

#handle(words) ⇒ Object

Finds the first Service that is able to handle the request and lets him do the work.

Parameters:

  • words (Array<String, Symbol>)


14
15
16
17
18
19
20
21
22
# File 'lib/inflect/director.rb', line 14

def handle(words)
  request = Inflect::Request.new(words)
  selected_service = select_service(request)
  if selected_service.nil?
    raise "No service can respond to #{request.keyword}"
  else
    selected_service.serve(request)
  end
end

#reloadObject



24
25
26
# File 'lib/inflect/director.rb', line 24

def reload
  service_provider.reload
end