Module: StewEucen::Acts::FertileForest::Entity
- Defined in:
- lib/fertile_forest/modules/entities.rb
Overview
Instance methods to include into derived class by ActiveRecord.
Instance Method Summary collapse
- #ancestors(columns = nil) ⇒ Object
- #children(columns = nil) ⇒ Object
- #cousins(columns = nil) ⇒ Object
- #descendants(columns = nil) ⇒ Object
- #elder_sibling(columns = nil) ⇒ Object
- #genitor(columns = nil) ⇒ Object
- #grandchildren(columns = nil) ⇒ Object
- #grandparent(columns = nil) ⇒ Object
- #height ⇒ Object
- #internals(columns = nil) ⇒ Object
- #kinships(next_branch = KINSHIPS_AS_SIBLING, level_offset = KINSHIPS_SAME_LEVEL, columns = nil) ⇒ Object
- #leaves(columns = nil) ⇒ Object
- #nest_child_ids ⇒ Object
- #nest_child_nodes ⇒ Object (also: #nest_children)
- #nest_leaf? ⇒ Boolean
- #nest_parent? ⇒ Boolean
- #nest_parent_id ⇒ Object
-
#nest_parent_node ⇒ Object
(also: #nest_parent, #nest_genitor)
accessors.
- #nest_set_child_id(aim_id) ⇒ Object
- #nest_set_child_node(aim_id, node) ⇒ Object
- #nest_set_parent_id(aim_id) ⇒ Object
- #nest_set_parent_node(aim_id, node) ⇒ Object
- #nest_unset_children(id = nil) ⇒ Object
- #nest_unset_parent ⇒ Object
- #niblings(columns = nil) ⇒ Object
- #nth_child(nth = 0, columns = nil) ⇒ Object
- #nth_sibling(nth = 0, columns = nil) ⇒ Object
- #offset_sibling(offset, columns = nil) ⇒ Object
- #piblings(columns = nil) ⇒ Object
- #root(columns = nil) ⇒ Object
- #siblings(columns = nil) ⇒ Object
- #size ⇒ Object
- #subtree(range = DESCENDANTS_ALL, with_top = true, columns = nil) ⇒ Object
- #trunk(range = ANCESTOR_ALL, columns = nil) ⇒ Object
- #younger_sibling(columns = nil) ⇒ Object
Instance Method Details
#ancestors(columns = nil) ⇒ Object
155 156 157 |
# File 'lib/fertile_forest/modules/entities.rb', line 155 def ancestors(columns = nil) self.class.ancestors(self, columns) end |
#children(columns = nil) ⇒ Object
179 180 181 |
# File 'lib/fertile_forest/modules/entities.rb', line 179 def children(columns = nil) self.class.children(self, columns) end |
#cousins(columns = nil) ⇒ Object
205 206 207 |
# File 'lib/fertile_forest/modules/entities.rb', line 205 def cousins(columns = nil) self.class.cousins(self, columns) end |
#descendants(columns = nil) ⇒ Object
175 176 177 |
# File 'lib/fertile_forest/modules/entities.rb', line 175 def descendants(columns = nil) self.class.descendants(self, columns) end |
#elder_sibling(columns = nil) ⇒ Object
223 224 225 |
# File 'lib/fertile_forest/modules/entities.rb', line 223 def elder_sibling(columns = nil) self.class.elder_sibling(self, columns) end |
#genitor(columns = nil) ⇒ Object
159 160 161 |
# File 'lib/fertile_forest/modules/entities.rb', line 159 def genitor(columns = nil) self.class.genitor(self, columns) end |
#grandchildren(columns = nil) ⇒ Object
187 188 189 |
# File 'lib/fertile_forest/modules/entities.rb', line 187 def grandchildren(columns = nil) self.class.grandchildren(self, columns) end |
#grandparent(columns = nil) ⇒ Object
167 168 169 |
# File 'lib/fertile_forest/modules/entities.rb', line 167 def grandparent(columns = nil) self.class.grandparent(self, columns) end |
#height ⇒ Object
243 244 245 |
# File 'lib/fertile_forest/modules/entities.rb', line 243 def height self.class.height(self) end |
#internals(columns = nil) ⇒ Object
239 240 241 |
# File 'lib/fertile_forest/modules/entities.rb', line 239 def internals(columns = nil) self.class.internals(self, columns) end |
#kinships(next_branch = KINSHIPS_AS_SIBLING, level_offset = KINSHIPS_SAME_LEVEL, columns = nil) ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/fertile_forest/modules/entities.rb', line 192 def kinships( next_branch = KINSHIPS_AS_SIBLING, level_offset = KINSHIPS_SAME_LEVEL, columns = nil ) self.class.kinships(self, next_branch, level_offset, columns) end |
#leaves(columns = nil) ⇒ Object
235 236 237 |
# File 'lib/fertile_forest/modules/entities.rb', line 235 def leaves(columns = nil) self.class.leaves(self, columns) end |
#nest_child_ids ⇒ Object
109 110 111 |
# File 'lib/fertile_forest/modules/entities.rb', line 109 def nest_child_ids [:children].keys end |
#nest_child_nodes ⇒ Object Also known as: nest_children
101 102 103 |
# File 'lib/fertile_forest/modules/entities.rb', line 101 def nest_child_nodes [:children] end |
#nest_leaf? ⇒ Boolean
141 142 143 |
# File 'lib/fertile_forest/modules/entities.rb', line 141 def nest_leaf? [:children].blank? end |
#nest_parent? ⇒ Boolean
145 146 147 |
# File 'lib/fertile_forest/modules/entities.rb', line 145 def nest_parent? !nest_leaf? end |
#nest_parent_id ⇒ Object
105 106 107 |
# File 'lib/fertile_forest/modules/entities.rb', line 105 def nest_parent_id [:parent].keys.first end |
#nest_parent_node ⇒ Object Also known as: nest_parent, nest_genitor
accessors
97 98 99 |
# File 'lib/fertile_forest/modules/entities.rb', line 97 def nest_parent_node [:parent].values.first end |
#nest_set_child_id(aim_id) ⇒ Object
123 124 125 |
# File 'lib/fertile_forest/modules/entities.rb', line 123 def nest_set_child_id(aim_id) [:children][aim_id] = nil end |
#nest_set_child_node(aim_id, node) ⇒ Object
134 135 136 137 |
# File 'lib/fertile_forest/modules/entities.rb', line 134 def nest_set_child_node(aim_id, node) [:children][aim_id] = node \ if aim_id.present? && node.present? end |
#nest_set_parent_id(aim_id) ⇒ Object
119 120 121 |
# File 'lib/fertile_forest/modules/entities.rb', line 119 def nest_set_parent_id(aim_id) [:parent] = {aim_id => nil} # always overwrite end |
#nest_set_parent_node(aim_id, node) ⇒ Object
129 130 131 132 |
# File 'lib/fertile_forest/modules/entities.rb', line 129 def nest_set_parent_node(aim_id, node) [:parent] = {aim_id => node} \ if aim_id.present? && node.present? end |
#nest_unset_children(id = nil) ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/fertile_forest/modules/entities.rb', line 82 def nest_unset_children(id = nil) if id.blank? [:children] = {} else [:children][id] = nil end end |
#nest_unset_parent ⇒ Object
78 79 80 |
# File 'lib/fertile_forest/modules/entities.rb', line 78 def nest_unset_parent [:parent] = {0 => nil} end |
#niblings(columns = nil) ⇒ Object
210 211 212 |
# File 'lib/fertile_forest/modules/entities.rb', line 210 def niblings(columns = nil) self.class.niblings(self, columns) end |
#nth_child(nth = 0, columns = nil) ⇒ Object
183 184 185 |
# File 'lib/fertile_forest/modules/entities.rb', line 183 def nth_child(nth = 0, columns = nil) self.class.nth_child(self, nth, columns) end |
#nth_sibling(nth = 0, columns = nil) ⇒ Object
219 220 221 |
# File 'lib/fertile_forest/modules/entities.rb', line 219 def nth_sibling(nth = 0, columns = nil) self.class.nth_sibling(self, nth, columns) end |
#offset_sibling(offset, columns = nil) ⇒ Object
231 232 233 |
# File 'lib/fertile_forest/modules/entities.rb', line 231 def offset_sibling(offset, columns = nil) self.class.offset_sibling(self, offset, columns) end |
#piblings(columns = nil) ⇒ Object
215 216 217 |
# File 'lib/fertile_forest/modules/entities.rb', line 215 def piblings(columns = nil) self.class.piblings(self, columns) end |
#root(columns = nil) ⇒ Object
163 164 165 |
# File 'lib/fertile_forest/modules/entities.rb', line 163 def root(columns = nil) self.class.root(self, columns) end |
#siblings(columns = nil) ⇒ Object
200 201 202 |
# File 'lib/fertile_forest/modules/entities.rb', line 200 def siblings(columns = nil) self.class.siblings(self, columns) end |
#size ⇒ Object
247 248 249 |
# File 'lib/fertile_forest/modules/entities.rb', line 247 def size self.class.size(self) end |
#subtree(range = DESCENDANTS_ALL, with_top = true, columns = nil) ⇒ Object
171 172 173 |
# File 'lib/fertile_forest/modules/entities.rb', line 171 def subtree(range = DESCENDANTS_ALL, with_top = true, columns = nil) self.class.subtree(self, range, with_top, columns) end |
#trunk(range = ANCESTOR_ALL, columns = nil) ⇒ Object
151 152 153 |
# File 'lib/fertile_forest/modules/entities.rb', line 151 def trunk(range = ANCESTOR_ALL, columns = nil) self.class.trunk(self, range, columns) end |
#younger_sibling(columns = nil) ⇒ Object
227 228 229 |
# File 'lib/fertile_forest/modules/entities.rb', line 227 def younger_sibling(columns = nil) self.class.younger_sibling(self, columns) end |