class Inflect::Director

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

Public Instance Methods

handle(words) click to toggle source

Finds the first Service that is able to handle the request and lets him do the work. @param words [Array<String, Symbol>]

# 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
reload() click to toggle source
# File lib/inflect/director.rb, line 24
def reload
  service_provider.reload
end

Private Instance Methods

select_service(request) click to toggle source
# File lib/inflect/director.rb, line 30
def select_service(request)
  services.find do |service|
    service.valid? request
  end
end