Class: FriendlyId::Status
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
The id or name used as the finder argument.
-
#record ⇒ Object
The found result, if any.
Instance Method Summary collapse
-
#best? ⇒ Boolean
Did the find operation use the best available id?.
-
#friendly? ⇒ Boolean
Did the find operation use a friendly id?.
-
#initialize(options = {}) ⇒ Status
constructor
A new instance of Status.
-
#numeric? ⇒ Boolean
Did the find operation use a numeric id?.
Constructor Details
#initialize(options = {}) ⇒ Status
Returns a new instance of Status.
14 15 16 |
# File 'lib/friendly_id/status.rb', line 14 def initialize(={}) .each {|key, value| self.send("#{key}=".to_sym, value)} end |
Instance Attribute Details
#name ⇒ Object
The id or name used as the finder argument
9 10 11 |
# File 'lib/friendly_id/status.rb', line 9 def name @name end |
#record ⇒ Object
The found result, if any
12 13 14 |
# File 'lib/friendly_id/status.rb', line 12 def record @record end |
Instance Method Details
#best? ⇒ Boolean
Did the find operation use the best available id?
29 30 31 |
# File 'lib/friendly_id/status.rb', line 29 def best? record.friendly_id ? friendly? : true end |
#friendly? ⇒ Boolean
Did the find operation use a friendly id?
19 20 21 |
# File 'lib/friendly_id/status.rb', line 19 def friendly? !! name end |
#numeric? ⇒ Boolean
Did the find operation use a numeric id?
24 25 26 |
# File 'lib/friendly_id/status.rb', line 24 def numeric? !friendly? end |