Sha256: 0b9ba00a34e81c05ff38a556764d2de6deb83c96c59798de783ee2ebc391f17f
Contents?: true
Size: 629 Bytes
Versions: 7
Compression:
Stored size: 629 Bytes
Contents
class Use < MLS::Model include MLS::Slugger # has_ltree_hierarchy has_many :children, class_name: 'Use', foreign_key: 'parent_id', inverse_of: :parent has_and_belongs_to_many :units # has_and_belongs_to_many :properties def descendants(uses = nil) # Recursive self + children of children uses ||= [self] self.children.each do |child| uses << child uses = child.descendants(uses) end uses end # # Scope taken from https://github.com/RISCfuture/hierarchy/blob/master/lib/hierarchy.rb # def self.self_and_descendents_of(use) # where("path <@ ?", use.path) # end end
Version data entries
7 entries across 7 versions & 1 rubygems