Sha256: a3e1f6418e03db6396840d7bc97abf34f000bfb1d961cadeb19556b6a1ae3d8b
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
module Dust class Menu module ItemDependency extend ActiveSupport::Concern included do attr_accessible :filename, :nav_link, :active, :menu has_one :menu_item, :as => :linkable, :dependent => :destroy, :autosave => true, :class_name => Dust::MenuItem auto_build :menu_item end def match_path menu_item.url end def filename self.menu_item.url.gsub("/", "") end def filename=(filename) self.menu_item.url = "/#{filename}" end def active self.menu_item.active end def active=(active) self.menu_item.active = active end def nav_link self.menu_item.title end def nav_link=(filename) self.menu_item.title = filename end def menu self.menu_item.menu_id end def menu=(menu_id) self.menu_item.menu_id = menu_id end module ClassMethods def find_by_filename(filename) filename = "/#{filename}" where(:menu_items => {:url => filename}).joins(:menu_item).first end def new_with_menu_item(options={}) item = self.new item.build_menu_item item.assign_attributes options item end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dust-cms-0.0.07 | app/models/dust/menu/item_dependency.rb |
dust-cms-0.0.06 | app/models/dust/menu/item_dependency.rb |
dust-cms-0.0.05 | app/models/dust/menu/item_dependency.rb |