Module: Inflect::Loader

Defined in:
lib/inflect/loader.rb

Overview

Responsable for loading all the services for Inflect to comunicate with them and decide wich one will handle the request.

Class Method Summary collapse

Class Method Details

.locale(path = nil) ⇒ Object


30
31
32
# File 'lib/inflect/loader.rb', line 30

def self.locale(path = nil)
  @@locale ||= YAML.load_file(path || Inflect.configuration.locale_path)
end

.services(path) ⇒ Array

Loads all the services from the given path, sorted by PRIORITY from lowest (1) to highest (INFINITY).

Parameters:

  • path (String)

    A String indicating the path to the services directory.

Returns:

  • (Array)

    The Service Classes sorted by PRIORITY.


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/inflect/loader.rb', line 18

def self.services(path)
  services = []

  Dir["#{path}/*.rb"].each do |file|
    require "#{file}"

    filename = File.basename(file, '.rb')
    services << Inflect.const_get(filename.camelize).instance
  end
  services.sort
end