Module: MegaMenus::Editor
- Defined in:
- lib/mega_menus/editor.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
here we want a class method!.
Instance Method Summary collapse
- #children ⇒ Object
- #isChildOf(parent_id) ⇒ Object
- #isRootOf(child_id) ⇒ Object
- #setNotPublished ⇒ Object
- #setPublished ⇒ Object
Class Method Details
.included(base) ⇒ Object
here we want a class method!
4 5 6 |
# File 'lib/mega_menus/editor.rb', line 4 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#children ⇒ Object
61 62 63 |
# File 'lib/mega_menus/editor.rb', line 61 def children self.class.children(self.id) end |
#isChildOf(parent_id) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mega_menus/editor.rb', line 8 def isChildOf( parent_id) =self.id while( != 1) = self.class.().id if(===parent_id) return TRUE end end return FALSE end |
#isRootOf(child_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/mega_menus/editor.rb', line 19 def isRootOf( child_id) =self.id while(child_id!=1) child_id= self.class.(child_id).id if(===child_id) return TRUE end end return FALSE end |
#setNotPublished ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mega_menus/editor.rb', line 48 def setNotPublished self.published=FALSE self.save! parent_id=self.id =self.class.all .each do |m| if(m.isChildOf(parent_id)) m.published=FALSE m.save! end end end |
#setPublished ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mega_menus/editor.rb', line 31 def setPublished self.published=TRUE self.save! =self.id =self.class.all .each do |m| if(m.isChildOf()) m.published=TRUE m.save! end if(m.isRootOf()) m.published=TRUE m.save! end end end |