Module: CouchRest::Model::Slug::ClassMethods
- Defined in:
- lib/couchrest/model/slug.rb
Instance Method Summary collapse
Instance Method Details
#find(value) ⇒ Object
30 31 32 |
# File 'lib/couchrest/model/slug.rb', line 30 def find(value) self.by_slug(:key => value).first || super(value) end |
#generate_count_for_slug(slug_without_count) ⇒ Object
34 35 36 37 |
# File 'lib/couchrest/model/slug.rb', line 34 def generate_count_for_slug(slug_without_count) hash = self.by_slug_without_count(:reduce => true, :group => true, :key => slug_without_count)["rows"].try(:first) hash.nil? ? slug_without_count : "#{slug_without_count}-#{hash['value']}" end |
#slug(*props) ⇒ Object
26 27 28 |
# File 'lib/couchrest/model/slug.rb', line 26 def slug(*props) self.slugged_props = props.map(&:to_s) end |