Class: FriendlyId::Slugged::Status
- Inherits:
-
FriendlyId::Status
- Object
- FriendlyId::Status
- FriendlyId::Slugged::Status
- Defined in:
- lib/friendly_id/slugged.rb
Instance Attribute Summary collapse
-
#sequence ⇒ Object
Returns the value of attribute sequence.
-
#slug ⇒ Object
The slug that was used to find the model.
Attributes inherited from FriendlyId::Status
Instance Method Summary collapse
-
#best? ⇒ Boolean
Did the find operation use the best possible id? True if
id
is numeric, but the model has no slug, orid
is friendly and current. -
#current? ⇒ Boolean
Did the find operation use the current slug?.
-
#friendly? ⇒ Boolean
Did the find operation use a friendly id?.
- #friendly_id=(friendly_id) ⇒ Object
-
#outdated? ⇒ Boolean
Did the find operation use an outdated slug?.
Methods inherited from FriendlyId::Status
Constructor Details
This class inherits a constructor from FriendlyId::Status
Instance Attribute Details
#sequence ⇒ Object
Returns the value of attribute sequence.
6 7 8 |
# File 'lib/friendly_id/slugged.rb', line 6 def sequence @sequence end |
#slug ⇒ Object
The slug that was used to find the model.
34 35 36 |
# File 'lib/friendly_id/slugged.rb', line 34 def slug @slug end |
Instance Method Details
#best? ⇒ Boolean
Did the find operation use the best possible id? True if id
is numeric, but the model has no slug, or id
is friendly and current
10 11 12 |
# File 'lib/friendly_id/slugged.rb', line 10 def best? current? || (numeric? && !record.slug) end |
#current? ⇒ Boolean
Did the find operation use the current slug?
15 16 17 |
# File 'lib/friendly_id/slugged.rb', line 15 def current? !! slug && slug.current? end |
#friendly? ⇒ Boolean
Did the find operation use a friendly id?
20 21 22 |
# File 'lib/friendly_id/slugged.rb', line 20 def friendly? !! (name or slug) end |
#friendly_id=(friendly_id) ⇒ Object
24 25 26 |
# File 'lib/friendly_id/slugged.rb', line 24 def friendly_id=(friendly_id) @name, @sequence = friendly_id.parse_friendly_id(record.friendly_id_config.sequence_separator) end |
#outdated? ⇒ Boolean
Did the find operation use an outdated slug?
29 30 31 |
# File 'lib/friendly_id/slugged.rb', line 29 def outdated? !current? end |