Class: PushType::Node

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Customizable, Nestable, Presentable, Publishable, Templatable, Trashable, Unexposable
Defined in:
app/models/push_type/node.rb

Direct Known Subclasses

TestPage

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Presentable

#present!, #presenter_class

Methods included from Trashable

#restore!, #trashed?

Methods included from Publishable

#expired?, #scheduled?

Methods included from Unexposable

#exposed?

Methods included from Templatable

#template, #template_args

Methods included from Nestable

#child_nodes, #children, #custom_child_order?, #descendable?, #sortable?

Methods included from Customizable

#attribute_for_inspect, #fields

Class Method Details

.find_by_base64_id(secret) ⇒ Object



20
21
22
23
24
# File 'app/models/push_type/node.rb', line 20

def self.find_by_base64_id(secret)
  find Base64.urlsafe_decode64(secret)
rescue ArgumentError
  raise ActiveRecord::RecordNotFound
end

Instance Method Details

#base64_idObject



26
27
28
# File 'app/models/push_type/node.rb', line 26

def base64_id
  Base64.urlsafe_encode64 id.to_s
end

#orphan?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/push_type/node.rb', line 34

def orphan?
  parent && parent.trashed?
end


30
31
32
# File 'app/models/push_type/node.rb', line 30

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

#trash!Object



38
39
40
41
# File 'app/models/push_type/node.rb', line 38

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