Module: HasSlug::NotSluggableInstanceMethods

Defined in:
lib/has_slug/not_sluggable_instance_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#found_by_slugObject (readonly)

Returns the value of attribute found_by_slug.



2
3
4
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 2

def found_by_slug
  @found_by_slug
end

Instance Method Details

#found_by_slug!Object



4
5
6
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 4

def found_by_slug!
  @found_by_slug = true
end

#found_by_slug?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 8

def found_by_slug?
  @found_by_slug
end

#slugObject



16
17
18
19
20
21
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 16

def slug
  id   = self.send(self.class.primary_key)
  slug = self.sluggable.to_slug(:preserve => has_slug_options[:preserve])
  
  "#{id}-#{slug}"
end

#sluggableObject



12
13
14
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 12

def sluggable
  read_attribute(self.class.has_slug_options[:attribute])
end

#to_paramObject



23
24
25
# File 'lib/has_slug/not_sluggable_instance_methods.rb', line 23

def to_param
  self.slug
end