Module: Schnecke::InstanceMethods
- Defined in:
- lib/schnecke/schnecke.rb
Overview
Instance methods to include
Instance Method Summary collapse
-
#after_assign_slug(opts = {}) ⇒ Object
Callback that is handled after the slug is assigned.
-
#assign_slug(opts = {}) ⇒ Object
Assign the slug.
-
#before_assign_slug(opts = {}) ⇒ Object
Callback that is handled before the slug assignment process.
-
#reassign_slug(opts = {}) ⇒ Object
Reassign the slug.
Instance Method Details
#after_assign_slug(opts = {}) ⇒ Object
Callback that is handled after the slug is assigned
Unless an error is raised during the slug assignment process, this method will always be called regardless of whether or not the slug was assigned
96 97 98 |
# File 'lib/schnecke/schnecke.rb', line 96 def after_assign_slug(opts = {}) # Left blank, but can be implemented by user end |
#assign_slug(opts = {}) ⇒ Object
Assign the slug
This is automatically called before model validation.
Note, a slug will not be assigned if one already exists. If one needs to
force the assignment of a slug, pass force: true
68 69 70 71 72 |
# File 'lib/schnecke/schnecke.rb', line 68 def assign_slug(opts = {}) before_assign_slug(opts) perform_slug_assign(opts) after_assign_slug(opts) end |
#before_assign_slug(opts = {}) ⇒ Object
Callback that is handled before the slug assignment process.
When this is called, no validations, or decisions about whether or not a slug should be created have been made. As such, this will always run regardless of whether or not the slug assignment process proceeds or not.
88 89 90 |
# File 'lib/schnecke/schnecke.rb', line 88 def before_assign_slug(opts = {}) # Left blank, but can be implemented by user end |
#reassign_slug(opts = {}) ⇒ Object
Reassign the slug
Unlike assign_slug, this will cause a slug to be created even if one already exists.
78 79 80 81 |
# File 'lib/schnecke/schnecke.rb', line 78 def reassign_slug(opts = {}) opts[:force] = true assign_slug(opts) end |