Class: Ecm::CmsCore::Folder
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ecm::CmsCore::Folder
- Defined in:
- app/models/ecm/cms_core/folder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fullname ⇒ Object
- #to_s ⇒ Object
- #tree_label ⇒ Object
- #update_children ⇒ Object
- #update_path ⇒ Object
- #update_path! ⇒ Object
- #update_templates ⇒ Object
Class Method Details
.root_folders ⇒ Object
59 60 61 |
# File 'app/models/ecm/cms_core/folder.rb', line 59 def self.root_folders self.roots end |
Instance Method Details
#fullname ⇒ Object
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_s ⇒ Object
19 20 21 22 |
# File 'app/models/ecm/cms_core/folder.rb', line 19 def to_s self.fullname # self.tree_label end |
#tree_label ⇒ Object
24 25 26 |
# File 'app/models/ecm/cms_core/folder.rb', line 24 def tree_label "#{'    ' * self.level} |--#{self.basename}".html_safe end |
#update_children ⇒ Object
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_path ⇒ Object
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_templates ⇒ Object
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 |