Class: Mongoid::SleepingKingStudios::Sluggable::Metadata
- Inherits:
-
Concern::Metadata
- Object
- Hash
- Concern::Metadata
- Mongoid::SleepingKingStudios::Sluggable::Metadata
- Defined in:
- lib/mongoid/sleeping_king_studios/sluggable/metadata.rb
Overview
Stores information about a Sluggable concern.
Instance Attribute Summary
Attributes inherited from Concern::Metadata
Instance Method Summary collapse
-
#attribute ⇒ Symbol
The base attribute used to determine the slug value.
-
#attribute? ⇒ Boolean
True if the attribute is defined; otherwise false.
-
#lockable? ⇒ Boolean
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.
-
#value_to_slug(value) ⇒ String
Converts the given value to a valid slug string.
Methods inherited from Concern::Metadata
#characterize, #initialize, #relation_key, #relation_key?
Constructor Details
This class inherits a constructor from Mongoid::SleepingKingStudios::Concern::Metadata
Instance Method Details
#attribute ⇒ Symbol
The base attribute used to determine the slug value.
12 13 14 |
# File 'lib/mongoid/sleeping_king_studios/sluggable/metadata.rb', line 12 def attribute self[:attribute].to_s.intern end |
#attribute? ⇒ Boolean
Returns True if the attribute is defined; otherwise false.
17 18 19 |
# File 'lib/mongoid/sleeping_king_studios/sluggable/metadata.rb', line 17 def attribute? !!self[:attribute] end |
#lockable? ⇒ Boolean
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.
26 27 28 |
# File 'lib/mongoid/sleeping_king_studios/sluggable/metadata.rb', line 26 def lockable? !!self[:lockable] end |
#value_to_slug(value) ⇒ String
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.
37 38 39 |
# File 'lib/mongoid/sleeping_king_studios/sluggable/metadata.rb', line 37 def value_to_slug value value.to_s.parameterize end |