Class: Folder

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.root_foldersObject



55
56
57
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 55

def self.root_folders
  self.roots
end

Instance Method Details

#fullnameObject



24
25
26
27
28
29
30
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 24

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

#to_sObject



15
16
17
18
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 15

def to_s
  self.fullname
  # self.tree_label
end

#tree_labelObject



20
21
22
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 20

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

#update_childrenObject



43
44
45
46
47
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 43

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

#update_pathObject



32
33
34
35
36
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 32

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

#update_path!Object



38
39
40
41
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 38

def update_path!
  self.update_path
  self.save
end

#update_templatesObject



49
50
51
52
53
# File 'lib/generators/ecm/cms_core/models/templates/folder.rb', line 49

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