Module: Normatron::Filters::DasherizeFilter

Defined in:
lib/normatron/filters/dasherize_filter.rb

Overview

Replaces all underscores with dashes.

Examples:

Out of box

DasherizeFilter.call("monty_python") #=> "monty-python"

Using as model normalizer

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

See Also:

Class Method Summary collapse

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 dasherized String


26
27
28
# File 'lib/normatron/filters/dasherize_filter.rb', line 26

def self.call(input)
  input.kind_of?(String) ? input.dasherize : input
end