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

- (Object) sequence

Returns the value of attribute sequence



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

def sequence
  @sequence
end

- (Object) slug

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

- (Boolean) best?

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

- (Boolean) current?

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

- (Boolean) friendly?

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

- (Object) friendly_id=(friendly_id)



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

- (Boolean) outdated?

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