Sha256: f86d0a5795dac01f35c9e550b9c89257ee3ae551bce9771ab139f9c4c5a0bf15
Contents?: true
Size: 770 Bytes
Versions: 1
Compression:
Stored size: 770 Bytes
Contents
module Lookbook module HierarchicalCollection extend ActiveSupport::Concern included do def entities @_cache[:entities] ||= collect_ordered_entities(to_tree(include_hidden: true)) end def to_tree(include_hidden: false) @_cache[include_hidden ? :tree_with_hidden : :tree] ||= EntityTreeBuilder.call(@entities, include_hidden: include_hidden) end protected def collect_ordered_entities(start_node) start_node.inject([]) do |entities, node| entities.append(node.content? ? node.content : collect_ordered_entities(node)) end.flatten end def sort_entities @entities.sort_by! { |entity| [entity.depth, entity.position, entity.label] } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lookbook-1.4.0 | lib/lookbook/entities/collections/concerns/hierarchical_collection.rb |