Class: Ecm::CmsCore::Folder

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/ecm/cms_core/folder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.root_foldersObject



59
60
61
# File 'app/models/ecm/cms_core/folder.rb', line 59

def self.root_folders
  self.roots
end

Instance Method Details

#fullnameObject



28
29
30
31
32
33
34
# File 'app/models/ecm/cms_core/folder.rb', line 28

def fullname
  if self.basename == "/"
    "/"
  else
    "#{self.pathname}#{self.basename}/"
  end
end

#to_sObject



19
20
21
22
# File 'app/models/ecm/cms_core/folder.rb', line 19

def to_s
  self.fullname
  # self.tree_label
end

#tree_labelObject



24
25
26
# File 'app/models/ecm/cms_core/folder.rb', line 24

def tree_label
  "#{'    ' * self.level} |--#{self.basename}".html_safe
end

#update_childrenObject



47
48
49
50
51
# File 'app/models/ecm/cms_core/folder.rb', line 47

def update_children
  self.children.each do |folder|
    folder.update_path!
  end
end

#update_pathObject



36
37
38
39
40
# File 'app/models/ecm/cms_core/folder.rb', line 36

def update_path
  if self.parent
    self.pathname = self.parent.fullname
  end
end

#update_path!Object



42
43
44
45
# File 'app/models/ecm/cms_core/folder.rb', line 42

def update_path!
  self.update_path
  self.save
end

#update_templatesObject



53
54
55
56
57
# File 'app/models/ecm/cms_core/folder.rb', line 53

def update_templates
  self.templates.each do |template|
    template.update_pathname!
  end
end