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)
-
- (Object) name
The id or name used as the finder argument.
-
- (Object) record
The found result, if any.
Instance Method Summary (collapse)
-
- (Boolean) best?
Did the find operation use the best available id?.
-
- (Boolean) friendly?
Did the find operation use a friendly id?.
-
- (Status) initialize(options = {})
constructor
A new instance of Status.
-
- (Boolean) numeric?
Did the find operation use a numeric id?.
Constructor Details
- (Status) initialize(options = {})
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
- (Object) name
The id or name used as the finder argument
9 10 11 |
# File 'lib/friendly_id/status.rb', line 9 def name @name end |
- (Object) record
The found result, if any
12 13 14 |
# File 'lib/friendly_id/status.rb', line 12 def record @record end |
Instance Method Details
- (Boolean) best?
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 |
- (Boolean) friendly?
Did the find operation use a friendly id?
19 20 21 |
# File 'lib/friendly_id/status.rb', line 19 def friendly? !! name end |
- (Boolean) numeric?
Did the find operation use a numeric id?
24 25 26 |
# File 'lib/friendly_id/status.rb', line 24 def numeric? !friendly? end |