Sha256: 8d8af46963be7f525806fb02f514d7ae664288321e76eb5ebb90d49029885943
Contents?: true
Size: 703 Bytes
Versions: 1
Compression:
Stored size: 703 Bytes
Contents
module Refinery class Menu def initialize(objects = nil) objects.each do |item| item = item.to_refinery_menu_item if item.respond_to?(:to_refinery_menu_item) items << MenuItem.new(item.merge(:menu => self)) end if objects end attr_accessor :items def items @items ||= [] end def roots @roots ||= items.select {|item| item.parent_id.nil?} end def to_s items.map(&:title).join(' ') end def inspect items.map(&:inspect) end # The delegation is specified so crazily so that it works on 1.8.x and 1.9.x delegate *((Array.instance_methods - Object.instance_methods) << {:to => :items}) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-core-2.0.3 | lib/refinery/menu.rb |