Module: Normatron::Filters::TitleizeFilter

Extended by:
Helpers
Defined in:
lib/normatron/filters/titleize_filter.rb

Overview

Capitalizes the first character of each word.

Examples:

Out of box

TitleizeFilter.call("at your will!") #=> "At Your Will!"

Using as ActiveRecord::Base normalizer

normalize :attribute_a, :with => :titleize
normalize :attribute_b, :with => [:custom_filter, :titleize]

See Also:

Class Method Summary collapse

Methods included from Helpers

acronym_regex, acronyms, evaluate_regexp, inflections, mb_send

Class Method Details

.call(input) ⇒ String

Performs input conversion according to filter requirements.

This method returns the object itself when the first argument is not a String.

Parameters:

  • input (String)

    The String to be filtered

Returns:

  • (String)

    A new titleized String



30
31
32
# File 'lib/normatron/filters/titleize_filter.rb', line 30

def self.call(input)
  input.kind_of?(String) ? mb_send(:titleize, input) : input
end