Module: Normatron::Filters::DasherizeFilter

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

Class Method Summary collapse

Class Method Details

.evaluate(input) ⇒ String

Replaces all underscores with dashes.

Examples:

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

Using as ActiveRecord::Base normalizer

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

Parameters:

  • input (String)

    A character sequence

Returns:

  • (String)

    The dasherized character sequence or the object itself

See Also:



20
21
22
# File 'lib/normatron/filters/dasherize_filter.rb', line 20

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