Sha256: d14dc43e8bd6bcc5fba243377a86603d35e7046eb76e234427539c9db9cd5598
Contents?: true
Size: 705 Bytes
Versions: 11
Compression:
Stored size: 705 Bytes
Contents
module Refinery class Menu def initialize(objects = nil) append(objects) end def append(objects) Array(objects).each do |item| item = item.to_refinery_menu_item if item.respond_to?(:to_refinery_menu_item) items << MenuItem.new(self, item) end end attr_accessor :items def items @items ||= [] end def roots @roots ||= select { |item| item.orphan? && item.depth == minimum_depth } end def to_s map(&:title).join(' ') end delegate :inspect, :map, :select, :detect, :first, :last, :length, :size, :to => :items protected def minimum_depth map(&:depth).compact.min end end end
Version data entries
11 entries across 11 versions & 1 rubygems