Class Menu
In: app/models/menu.rb
Parent: ActiveRecord::Base

-*- coding: utf-8 -*-

Schema Information

Schema version: 87

Table name: menus

 id           :integer       not null, primary key
 domain_id    :integer       not null
 code         :string(255)   not null
 name_po      :integer       not null
 motion       :string(255)
 parent_id    :integer
 lft          :integer
 rgt          :integer
 product_id   :integer
 created_at   :string(14)
 updated_at   :string(14)
 created_by   :integer
 updated_by   :integer
 created_in   :integer
 updated_in   :integer
 lock_version :integer       default(0), not null

Methods

External Aliases

root -> nested_set_root
children -> nested_set_children

Public Class methods

メニューレイアウトでの根を返す。

[Source]

    # File app/models/menu.rb, line 39
39:   def self.root
40:     find(:first, :conditions => "menus.parent_id IS NULL", :order => "menus.id")
41:   end

Public Instance methods

necessary な子メニュー全体を返す。

[Source]

    # File app/models/menu.rb, line 50
50:   def children
51:     @children ||= nested_set_children.select(&:visible?)
52:   end

URL を構成するためのオプションを返す。

[Source]

    # File app/models/menu.rb, line 55
55:   def url_options
56:     return @url_options if defined?(@url_options)
57:     return {} unless self.motion
58:     @url_options = {}
59:     self.motion.scan(/(\w+)=(\w+)/) do |key, value|
60:       @url_options[key.to_sym] = value
61:     end
62:     return @url_options
63:   end

閲覧可能かどうかを判定する。

[Source]

    # File app/models/menu.rb, line 44
44:   def visible?
45:     return product.visible? if product
46:     return !children.empty?
47:   end

[Source]

    # File app/models/menu.rb, line 65
65:   def with_ajax?
66:     if /\A\// =~ motion
67:       return false
68:     else
69:       return true
70:     end
71:   end

[Validate]