Sha256: 807d1a9870aa9ed74dd88536e3dc81a50efb7ad020c8d3f16f455bd6c333e943

Contents?: true

Size: 371 Bytes

Versions: 1

Compression:

Stored size: 371 Bytes

Contents

module Geopolitical
  module Helpers
    extend ActiveSupport::Concern

    included do
      before_validation :set_slug
    end

    def to_s
      name || slug
    end

    def set_slug
      self.slug ||= name
    end

    def slug= txt
      return unless txt
      self[:slug] = txt.encode(Encoding::ISO_8859_1).
        gsub(/\s/, '-').downcase
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geopolitical-0.8.1 lib/geopolitical/helpers.rb