class Rooftop::Menus::Item
Public Class Methods
new(args)
click to toggle source
Calls superclass method
# File lib/rooftop/menus/item.rb, line 4 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
Public Instance Methods
object()
click to toggle source
# File lib/rooftop/menus/item.rb, line 16 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