class Mongoid::SleepingKingStudios::Sluggable::Metadata

Stores information about a Sluggable concern.

Public Instance Methods

attribute() click to toggle source

The base attribute used to determine the slug value.

@return [Symbol] The attribute name.

# File lib/mongoid/sleeping_king_studios/sluggable/metadata.rb, line 12
def attribute
  self[:attribute].to_s.intern
end
attribute?() click to toggle source

@return [Boolean] True if the attribute is defined; otherwise false.

# File lib/mongoid/sleeping_king_studios/sluggable/metadata.rb, line 17
def attribute?
  !!self[:attribute]
end
lockable?() click to toggle source

If true, the slug can be “locked” by setting the slug value directly or by setting the value of the :slug_lock field to true. A locked slug is not overwritten when the base field is updated.

@return [Boolean] True if the slug is lockable; otherwise false.

# File lib/mongoid/sleeping_king_studios/sluggable/metadata.rb, line 26
def lockable?
  !!self[:lockable]
end
value_to_slug(value) click to toggle source

Converts the given value to a valid slug string. Refactoring this into the metadata will permit customization of the value -> slug mapping in the future.

@param [Object] value The value to convert into a slug.

@return [String] The converted value.

# File lib/mongoid/sleeping_king_studios/sluggable/metadata.rb, line 37
def value_to_slug value
  value.to_s.parameterize
end