Module: MemoizedInflectors

Defined in:
lib/memoized_inflectors.rb,
lib/memoized_inflectors/version.rb

Constant Summary collapse

INFLECTOR_METHODS =
[
  :camelize, :classify, :constantize, :dasherize, :deconstantize, :demodulize, :foreign_key,
  :humanize, :inflections, :ordinal, :ordinalize, :parameterize, :pluralize, :safe_constantize,
  :singularize, :tableize, :titleize, :transliterate, :underscore
].freeze
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.prepended(klass) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/memoized_inflectors.rb', line 12

def self.prepended(klass)
  klass.class_eval do
    @memoized_inflectors = {}
    INFLECTOR_METHODS.each do |inflector_name|
      unless instance_variable_get("@#{ inflector_name }")
        @memoized_inflectors[inflector_name] = instance_variable_set("@#{ inflector_name }", {})
      end
    end
  end
end