Sha256: 3be9231fba196672028d876a7356ccdc1a34f4c1a50b722966605b928edc0318

Contents?: true

Size: 774 Bytes

Versions: 60

Compression:

Stored size: 774 Bytes

Contents

module FriendlyId

  # FriendlyId::Status presents information about the status of the
  # id that was used to find the model. This class can be useful for figuring
  # out when to redirect to a new URL.
  class Status

    # The id or name used as the finder argument
    attr_accessor :name

    # The found result, if any
    attr_accessor :record

    def initialize(options={})
      options.each {|key, value| self.send("#{key}=".to_sym, value)}
    end

    # Did the find operation use a friendly id?
    def friendly?
      !! name
    end

    # Did the find operation use a numeric id?
    def numeric?
      !friendly?
    end

    # Did the find operation use the best available id?
    def best?
      record.friendly_id ? friendly? : true
    end

  end

end

Version data entries

60 entries across 60 versions & 4 rubygems

Version Path
friendly_id-3.3.3.0 lib/friendly_id/status.rb
friendly_id-3.3.2.0 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.6 lib/friendly_id/status.rb
friendly_id-3.3.1.1 lib/friendly_id/status.rb
friendly_id-3.3.1 lib/friendly_id/status.rb
friendly_id-3.3.0.1 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.5 lib/friendly_id/status.rb
friendly_id-4.0.0.beta7 lib/friendly_id/status.rb
friendly_id-3.3.0.rc2 lib/friendly_id/status.rb
friendly_id-3.3.0.rc1 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.4 lib/friendly_id/status.rb
friendly_id-3.3.0.alpha2 lib/friendly_id/status.rb
friendly_id-3.3.0.alpha1 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.3 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.2 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1.1 lib/friendly_id/status.rb
friendly_id-3.2.1.1 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.1 lib/friendly_id/status.rb
friendly_id-3.2.1 lib/friendly_id/status.rb
friendly_id_globalize3-3.2.0 lib/friendly_id/status.rb