Sha256: 53c4c4596fc6dbb37fed4a497a1424accc2ea17b2808ecd657e59281810505fd

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

module FriendlyId
  # Utility methods that are in Object because it's impossible to predict what
  # kinds of objects get passed into FinderMethods#find_one and
  # Model#normalize_friendly_id.
  module ObjectUtils

    # True is the id is definitely friendly, false if definitely unfriendly,
    # else nil.
    def friendly_id?
      if kind_of?(Integer) or kind_of?(Symbol) or self.class.respond_to? :friendly_id_config
        false
      elsif to_i.to_s != to_s
        true
      end
    end

    # True if the id is definitely unfriendly, false if definitely friendly,
    # else nil.
    def unfriendly_id?
      val = friendly_id? ; !val unless val.nil?
    end
  end
end

class Object
  include FriendlyId::ObjectUtils
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
friendly_id4-4.0.0.beta1 lib/friendly_id/object_utils.rb
friendly_id4-4.0.0.pre3 lib/friendly_id/object_utils.rb