Module: DataMapper::Is::Slug::InstanceMethods

Defined in:
lib/dm-is-slug/is/slug.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#slug_mutable?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/dm-is-slug/is/slug.rb', line 138

def slug_mutable?
  self.class.slug_mutable?
end

#slug_propertyObject



150
151
152
# File 'lib/dm-is-slug/is/slug.rb', line 150

def slug_property
  self.class.slug_property
end

#slug_sourceObject



142
143
144
# File 'lib/dm-is-slug/is/slug.rb', line 142

def slug_source
  self.class.slug_source
end

#slug_source_propertyObject



146
147
148
# File 'lib/dm-is-slug/is/slug.rb', line 146

def slug_source_property
  self.class.slug_source_property
end

#slug_source_valueObject



154
155
156
# File 'lib/dm-is-slug/is/slug.rb', line 154

def slug_source_value
  self.send(slug_source)
end

#stale_slug?Boolean

The slug is not stale if

  1. the slug is permanent, and slug column has something valid in it

  2. the slug source value is nil or empty

Returns:

  • (Boolean)


161
162
163
# File 'lib/dm-is-slug/is/slug.rb', line 161

def stale_slug?
  !((!slug_mutable? && slug && !slug.empty?) || (slug_source_value.nil? || slug_source_value.empty?))
end

#to_paramObject



134
135
136
# File 'lib/dm-is-slug/is/slug.rb', line 134

def to_param
  [slug]
end