Sha256: 03577aa9e980f3cfb5db7bd218013dc52a583db0746c6efd376f8959940be9b0

Contents?: true

Size: 850 Bytes

Versions: 34

Compression:

Stored size: 850 Bytes

Contents

module PushType
  class Node < ActiveRecord::Base

    include PushType::Customizable
    include PushType::Nestable
    include PushType::Templatable
    include PushType::Unexposable
    include PushType::Publishable
    include PushType::Trashable
    include PushType::Presentable

    belongs_to :creator, class_name: 'PushType::User'
    belongs_to :updater, class_name: 'PushType::User'

    acts_as_tree name_column: 'slug', order: 'sort_order', dependent: :destroy

    validates :title, presence: true
    validates :slug,  presence: true, uniqueness: { scope: :parent_id }

    def permalink
      @permalink ||= self_and_ancestors.map(&:slug).reverse.join('/')
    end

    def orphan?
      parent && parent.trashed?
    end

    def trash!  
      super
      self.descendants.update_all deleted_at: Time.zone.now
    end
    
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
push_type_core-0.10.0.beta.3 app/models/push_type/node.rb
push_type_core-0.9.5 app/models/push_type/node.rb
push_type_core-0.9.3 app/models/push_type/node.rb
push_type_core-0.9.2 app/models/push_type/node.rb
push_type_core-0.9.1 app/models/push_type/node.rb
push_type_core-0.9.0 app/models/push_type/node.rb
push_type_core-0.9.0.beta.4 app/models/push_type/node.rb
push_type_core-0.9.0.beta.3 app/models/push_type/node.rb
push_type_core-0.9.0.beta.2 app/models/push_type/node.rb
push_type_core-0.8.2 app/models/push_type/node.rb
push_type_core-0.8.1 app/models/push_type/node.rb
push_type_core-0.8.0 app/models/push_type/node.rb
push_type_core-0.8.0.beta.3 app/models/push_type/node.rb
push_type_core-0.8.0.beta.2 app/models/push_type/node.rb
push_type_core-0.8.0.beta.1 app/models/push_type/node.rb
push_type_core-0.7.0 app/models/push_type/node.rb
push_type_core-0.7.0.beta.1 app/models/push_type/node.rb
push_type_core-0.6.0 app/models/push_type/node.rb
push_type_core-0.6.0.beta.4 app/models/push_type/node.rb
push_type_core-0.6.0.beta.3 app/models/push_type/node.rb