module ROM::Inflector

Helper module providing thin interface around an inflection backend.

@private

Constants

BACKENDS

Public Class Methods

camelize(input) click to toggle source
# File lib/rom/support/inflector.rb, line 45
def self.camelize(input)
  inflector.camelize(input)
end
classify(input) click to toggle source
# File lib/rom/support/inflector.rb, line 69
def self.classify(input)
  inflector.classify(input)
end
constantize(input) click to toggle source
# File lib/rom/support/inflector.rb, line 65
def self.constantize(input)
  inflector.constantize(input)
end
demodulize(input) click to toggle source
# File lib/rom/support/inflector.rb, line 61
def self.demodulize(input)
  inflector.demodulize(input)
end
detect_backend() click to toggle source
# File lib/rom/support/inflector.rb, line 24
def self.detect_backend
  BACKENDS.find do |_, (path, inflector_class)|
    backend = realize_backend(path, inflector_class)
    break backend if backend
  end ||
    raise(LoadError,
          "No inflector library could be found: "\
          "please install either the `inflecto` or `activesupport` gem.")
end
inflector() click to toggle source
# File lib/rom/support/inflector.rb, line 41
def self.inflector
  defined?(@inflector) && @inflector || select_backend
end
pluralize(input) click to toggle source
# File lib/rom/support/inflector.rb, line 57
def self.pluralize(input)
  inflector.pluralize(input)
end
realize_backend(path, inflector_backend_factory) click to toggle source
# File lib/rom/support/inflector.rb, line 17
def self.realize_backend(path, inflector_backend_factory)
  require path
  inflector_backend_factory.call
rescue LoadError
  nil
end
select_backend(name = nil) click to toggle source
# File lib/rom/support/inflector.rb, line 34
def self.select_backend(name = nil)
  if name && !BACKENDS.key?(name)
    raise NameError, "Invalid inflector library selection: '#{name}'"
  end
  @inflector = name ? realize_backend(*BACKENDS[name]) : detect_backend
end
singularize(input) click to toggle source
# File lib/rom/support/inflector.rb, line 53
def self.singularize(input)
  inflector.singularize(input)
end
underscore(input) click to toggle source
# File lib/rom/support/inflector.rb, line 49
def self.underscore(input)
  inflector.underscore(input)
end