Sha256: c560c2a7513f14a039c237eb5472315a32ad5b9e512e4e90582af0346ca65854
Contents?: true
Size: 801 Bytes
Versions: 7
Compression:
Stored size: 801 Bytes
Contents
module Rooftop module Menus class Item < OpenStruct def initialize(args) args[:object_type] = args[:object] super # If this menu item has children, create a MenuItem for each one if self.children self.children = children.collect do |child| Item.new(child) end end end def object if self.type == "post_type" begin klass = Rooftop.configuration.post_type_mapping[self.object_type] || self.object_type.classify.constantize klass.find_by(slug: self.slug).first rescue raise UnmappedObjectError, "Couldn't find an mapping between the #{self.object_type} post type and a class in your code." end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems