Sha256: 2de13b5565afc04f753db3c83ea823e2a050fdacd283770fe67cb98ec4789639

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

Contents

require 'slugs/extensions/action_dispatch/generator'
require 'slugs/extensions/action_dispatch/optimized_url_helper'
require 'slugs/extensions/active_record/base'
require 'slugs/concern'
require 'slugs/configuration'
require 'slugs/railtie'

module Slugs
  class << self

    def configuration
      @configuration ||= Configuration.new
    end

    def configure
      yield configuration
    end

    def parameterize(record, params)
      if use_slug_for?(record, params)
        if record.slug_changed?
          record.slug_was
        else
          record.slug
        end
      else
        record.to_param
      end
    end

    def use_slug_for?(record, params)
      if record.try(:sluggable?) && configuration.use_slug_proc
        configuration.use_slug_proc.call record, params
      else
        false
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slugs-2.0.1 lib/slugs.rb
slugs-2.0.0 lib/slugs.rb