Class: FriendlyId::ActiveRecordAdapter::Configuration

Inherits:
Configuration 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, #default_locale, #locale, #max_length, #method, #reserved_message, #reserved_words, #scope, #sequence_separator, #strip_non_ascii, #use_slug

Instance Method Summary collapse

Methods inherited from Configuration

#babosa_options, #initialize, locales_used?, #reserved?, #reserved_error_message, scopes_used=, scopes_used?

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)


42
43
44
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 42

def custom_cache_column?
  !! custom_cache_column
end

#scope_for(record) ⇒ Object



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

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

#scopes_over?(klass) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/friendly_id/active_record_adapter/configuration.rb', line 51

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