Sha256: 316e56eddf978f336b98949203f4f26c110707ff91a8603a15d8512ae55241e0

Contents?: true

Size: 423 Bytes

Versions: 1

Compression:

Stored size: 423 Bytes

Contents

# encoding: utf-8

module PagesCore
  module HumanizableParam
    extend ActiveSupport::Concern

    def humanized_param(slug)
      return id.to_s unless slug && !slug.blank?
      "#{id}-" + slug
                 .gsub(/[\[\{]/, "(")
                 .gsub(/[\]\}]/, ")")
                 .gsub(/[^[[:alnum:]]()\-]+/, "-")
                 .gsub(/[\-]{2,}/, "-")
                 .gsub(/(^\-|\-$)/, "")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.5.1 app/models/concerns/pages_core/humanizable_param.rb