Class: FriendlyId::ActiveRecordAdapter::Configuration

Inherits:
Configuration
  • Object
show all
Defined in:
lib/friendly_id/active_record_adapter/configuration.rb

Overview

Extends FriendlyId::Configuration with some implementation details and features specific to ActiveRecord.

Constant Summary

Constants inherited from Configuration

Configuration::DEFAULTS

Instance Attribute Summary collapse

Attributes inherited from Configuration

#allow_nil, #approximate_ascii, #ascii_approximation_options, #configured_class, #max_length, #method, #reserved_message, #reserved_words, #scope, #sequence_separator, #strip_non_ascii, #use_slug

Instance Method Summary collapse

Methods inherited from Configuration

#initialize, #reserved?, #reserved_error_message

Constructor Details

This class inherits a constructor from FriendlyId::Configuration

Instance Attribute Details

#cache_columnObject

The column used to cache the friendly_id string. If no column is specified, FriendlyId will look for a column named cached_slug and use it automatically if it exists. If for some reason you have a column named cached_slug but don’t want FriendlyId to modify it, pass the option :cache_column => false to has_friendly_id.



14
15
16
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 14

def cache_column
  @cache_column
end

#child_scopesObject (readonly)

An array of classes for which the configured class serves as a FriendlyId scope.



18
19
20
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 18

def child_scopes
  @child_scopes
end

#custom_cache_columnObject (readonly)

Returns the value of attribute custom_cache_column.



20
21
22
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 20

def custom_cache_column
  @custom_cache_column
end

Instance Method Details

#cache_column?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 27

def cache_column?
  !! cache_column
end

#custom_cache_column?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 40

def custom_cache_column?
  !! custom_cache_column
end

#scope_for(record) ⇒ Object



44
45
46
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 44

def scope_for(record)
  scope? ? record.send(scope).to_param : nil
end

#scopes_over?(klass) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 48

def scopes_over?(klass)
  scope? && scope == klass.to_s.underscore.to_sym
end