Module: Dolly::Slugable
- Defined in:
- lib/dolly/slugable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/dolly/slugable.rb', line 5 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#id ⇒ Object
26 27 28 |
# File 'lib/dolly/slugable.rb', line 26 def id doc[:_id] ||= self.class.namespace_key(slug) end |
#normalize_property ⇒ Object
30 31 32 33 34 |
# File 'lib/dolly/slugable.rb', line 30 def normalize_property proc do |property| send(:"#{property}").to_s end end |
#parameterize_item ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/dolly/slugable.rb', line 16 def parameterize_item proc do || if .respond_to?(:parameterize) next .parameterize end end end |
#slug ⇒ Object
9 10 11 12 13 14 |
# File 'lib/dolly/slugable.rb', line 9 def slug slugable_properties. map(&normalize_property). map(¶meterize_item). join(slugable_separator) end |