Module: DataMapper::Is::Slug::AliasMethods
- Included in:
- Collection, Model
- Defined in:
- lib/dm-is-slug/is/slug.rb
Overview
InstanceMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
fired when your plugin gets included into Resource.
Instance Method Summary collapse
-
#get_with_slug(*key) ⇒ Object
override the old get method so that it looks for slugs first and call the old get if slug is not found.
Class Method Details
.included(base) ⇒ Object
fired when your plugin gets included into Resource
200 201 202 203 |
# File 'lib/dm-is-slug/is/slug.rb', line 200 def self.included(base) base.send :alias_method, :get_without_slug, :get base.send :alias_method, :get, :get_with_slug end |
Instance Method Details
#get_with_slug(*key) ⇒ Object
override the old get method so that it looks for slugs first and call the old get if slug is not found
190 191 192 193 194 195 196 |
# File 'lib/dm-is-slug/is/slug.rb', line 190 def get_with_slug(*key) if respond_to?(:slug_options) && && key[0].to_s.to_i.to_s != key[0].to_s first(:slug => key[0]) else get_without_slug(*key) end end |