Sha256: dacb3b36f12a0e04ba29e0c360c820c7c81098435fce7734fa7870af50ec1bff
Contents?: true
Size: 695 Bytes
Versions: 6
Compression:
Stored size: 695 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).min end end end
Version data entries
6 entries across 6 versions & 1 rubygems