module Sunrise::Models::Structure

Public Instance Methods

descendants_count() click to toggle source
# File lib/sunrise/models/structure.rb, line 47
def descendants_count
  (right - left - 1) / 2
end
moveable?() click to toggle source
# File lib/sunrise/models/structure.rb, line 43
def moveable?
  new_record? || !root?
end

Protected Instance Methods

generate_slug() click to toggle source
# File lib/sunrise/models/structure.rb, line 53
def generate_slug
  self.slug = Sunrise::Utils.normalize_friendly_id(title)
end
should_generate_new_slug?() click to toggle source
# File lib/sunrise/models/structure.rb, line 57
def should_generate_new_slug?
  base = title
  slug_value = slug

  # If the slug base is nil, and the slug field is nil, then we're going to leave the slug column NULL.
  return false if base.nil? && slug_value.nil?

  # Otherwise, if this is a new record, we're definitely going to try to create a new slug.
  slug_value.blank?
end