Class: FriendlyId::Slugged::Status

Inherits:
FriendlyId::Status show all
Defined in:
lib/friendly_id/slugged.rb

Instance Attribute Summary collapse

Attributes inherited from FriendlyId::Status

#name, #record

Instance Method Summary collapse

Methods inherited from FriendlyId::Status

#initialize, #numeric?

Constructor Details

This class inherits a constructor from FriendlyId::Status

Instance Attribute Details

#sequenceObject

Returns the value of attribute sequence.



6
7
8
# File 'lib/friendly_id/slugged.rb', line 6

def sequence
  @sequence
end

#slugObject

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

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


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?

Returns:

  • (Boolean)


29
30
31
# File 'lib/friendly_id/slugged.rb', line 29

def outdated?
  !current?
end