Sha256: b85d7f134617202a8c18ff9bebfed0b7a4954f33b6fc3529e7e521c3716812f5

Contents?: true

Size: 421 Bytes

Versions: 1

Compression:

Stored size: 421 Bytes

Contents

module Geopolitical
  # Geopolitical Helpers TODO move to concerns?
  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.2 lib/geopolitical/helpers.rb