Class: Faalis::Dashboard::Models::Item
- Inherits:
-
Object
- Object
- Faalis::Dashboard::Models::Item
- Defined in:
- lib/faalis/dashboard/models/sidebar.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#members_only ⇒ Object
readonly
Returns the value of attribute members_only.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(title, options) ⇒ Item
constructor
A new instance of Item.
- #visible?(user) ⇒ Boolean
Constructor Details
#initialize(title, options) ⇒ Item
Returns a new instance of Item.
5 6 7 8 9 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 5 def initialize(title, ) @title = title @model = nil () end |
Instance Attribute Details
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
4 5 6 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 4 def icon @icon end |
#members_only ⇒ Object (readonly)
Returns the value of attribute members_only.
4 5 6 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 4 def members_only @members_only end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
4 5 6 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 4 def model @model end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 4 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 4 def url @url end |
Instance Method Details
#visible?(user) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/faalis/dashboard/models/sidebar.rb', line 11 def visible?(user) return true if @model.nil? if @model.respond_to? :map = @model.map do |model| # Find the appropriate policy for each model # and authorize the user against that. Pundit.policy!(user, model.to_sym).index? end # If user don't have access to none of the models # then the menu should not be visible .any? else # Authorize the menu visibility against user and given model Pundit.policy!(user, @model.to_sym).index? end end |