Class: Lipsiadmin::AccessControl::ProjectModule
- Inherits:
-
Object
- Object
- Lipsiadmin::AccessControl::ProjectModule
- Includes:
- ActionController::UrlWriter, Helper
- Defined in:
- lib/access_control/base.rb
Instance Attribute Summary collapse
-
#menus ⇒ Object
readonly
Returns the value of attribute menus.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#allowed ⇒ Object
Return allowed controllers.
-
#config ⇒ Object
Return ExtJs Config for this project module.
-
#human_name ⇒ Object
Return the original name or try to translate or humanize the symbol.
-
#initialize(name, path = nil, options = {}) {|_self| ... } ⇒ ProjectModule
constructor
:nodoc:.
-
#menu(name, path = nil, options = {}, &block) ⇒ Object
Build a new menu and automaitcally add the action on the allowed actions.
-
#uid ⇒ Object
Return a unique id for the given project module.
Methods included from Helper
Constructor Details
#initialize(name, path = nil, options = {}) {|_self| ... } ⇒ ProjectModule
:nodoc:
140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/access_control/base.rb', line 140 def initialize(name, path=nil, ={}, &block)#:nodoc: @name = name @options = @allowed = [] @menus = [] if path @url = recognize_path(path) @allowed << { :controller => @url[:controller] } end yield self end |
Instance Attribute Details
#menus ⇒ Object (readonly)
Returns the value of attribute menus.
138 139 140 |
# File 'lib/access_control/base.rb', line 138 def @menus end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
138 139 140 |
# File 'lib/access_control/base.rb', line 138 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
138 139 140 |
# File 'lib/access_control/base.rb', line 138 def url @url end |
Instance Method Details
#allowed ⇒ Object
Return allowed controllers
158 159 160 161 |
# File 'lib/access_control/base.rb', line 158 def allowed @menus.each { |m| @allowed.concat(m.allowed) } @allowed.uniq end |
#config ⇒ Object
Return ExtJs Config for this project module
174 175 176 177 178 179 |
# File 'lib/access_control/base.rb', line 174 def config = @options.merge(:text => human_name) .merge!(:menu => @menus.collect(&:config)) if @menus.size > 0 .merge!(:handler => "function(){ Backend.app.load('#{url_for(@url.merge(:only_path => true))}') }".to_l) if @url end |
#human_name ⇒ Object
Return the original name or try to translate or humanize the symbol
164 165 166 |
# File 'lib/access_control/base.rb', line 164 def human_name @name.is_a?(Symbol) ? I18n.t("backend.menus.#{@name}", :default => @name.to_s.humanize) : @name end |
#menu(name, path = nil, options = {}, &block) ⇒ Object
Build a new menu and automaitcally add the action on the allowed actions.
153 154 155 |
# File 'lib/access_control/base.rb', line 153 def (name, path=nil, ={}, &block) @menus << Menu.new(name, path, , &block) end |
#uid ⇒ Object
Return a unique id for the given project module
169 170 171 |
# File 'lib/access_control/base.rb', line 169 def uid @name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '') end |