Sha256: 96058069ad5bba581b82cb6b3982b528a0616b16d4e7e30d70e4ad6444edef09
Contents?: true
Size: 1010 Bytes
Versions: 1
Compression:
Stored size: 1010 Bytes
Contents
require "active_record" require "permalink/active_record" require "permalink/normalizations/contraction" require "permalink/normalizations/downcase" require "permalink/normalizations/leading_trailing_dashes" require "permalink/normalizations/multiple_dashes" require "permalink/normalizations/non_alphanumeric" require "permalink/normalizations/transliteration" module Permalink DEFAULT_NORMALIZATIONS = [ Normalizations::Transliteration, Normalizations::Downcase, Normalizations::Contraction, Normalizations::NonAlphanumeric, Normalizations::MultipleDashes, Normalizations::LeadingTrailingDashes ] DEFAULT_OPTIONS = { normalizations: DEFAULT_NORMALIZATIONS, separator: "-" } def self.generate(input, options = DEFAULT_OPTIONS) options = DEFAULT_OPTIONS.merge(options) options[:normalizations].each do |normalization| input = normalization.call(input, options) end input end end ActiveRecord::Base.send(:include, Permalink::ActiveRecord)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
permalink-2.0.0 | lib/permalink.rb |