Class: Pennyworth::Inflector

Inherits:
Object
  • Object
show all
Defined in:
lib/pennyworth/inflector.rb

Overview

Overrides any string to desired form if matched, otherwise answers the original string.

Constant Summary collapse

DEFAULTS =
Array(Container[:settings].inflections).reduce({}, :merge)

Instance Method Summary collapse

Constructor Details

#initialize(overrides = DEFAULTS) ⇒ Inflector

Returns a new instance of Inflector.



8
9
10
# File 'lib/pennyworth/inflector.rb', line 8

def initialize overrides = DEFAULTS
  @overrides = overrides
end

Instance Method Details

#call(key) ⇒ Object



12
# File 'lib/pennyworth/inflector.rb', line 12

def call(key) = overrides.fetch(key) { |fallback| fallback }