Class: SimpleSlugs::Slugger
- Inherits:
-
ActiveSupport::InheritableOptions
- Object
- ActiveSupport::InheritableOptions
- SimpleSlugs::Slugger
- Defined in:
- lib/simple_slugs/slugger.rb
Constant Summary collapse
- DEFAULTS =
{ :slug_name => :slug, :on_blank => true, :scope => nil, :separator => '-' }
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, options) ⇒ Slugger
constructor
A new instance of Slugger.
- #unique_slug!(record) ⇒ Object
Constructor Details
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
13 14 15 |
# File 'lib/simple_slugs/slugger.rb', line 13 def model @model end |
Instance Method Details
#unique_slug!(record) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/simple_slugs/slugger.rb', line 20 def unique_slug!(record) if record.send(slug_name).blank? || !on_blank source = record.send(self.source) record.slug = ensure_unique_slug(record, source.to_slug) if source end end |