Class: Interview::NavigationItem
- Includes:
- HasControls
- Defined in:
- lib/interview/navigation_item.rb,
lib/interview/navigation_item_old.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#active ⇒ Object
Returns the value of attribute active.
-
#badge_formula ⇒ Object
Returns the value of attribute badge_formula.
-
#caption ⇒ Object
Returns the value of attribute caption.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#image ⇒ Object
Returns the value of attribute image.
-
#object ⇒ Object
Returns the value of attribute object.
-
#trail ⇒ Object
Returns the value of attribute trail.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes included from HasControls
Attributes inherited from Link
#hint, #html_class, #nested_resource, #redirect_to, #style, #url_params
Attributes inherited from Control
Instance Method Summary collapse
Methods included from HasControls
#add_control, #add_controls, included, #initialize, #siblings
Methods inherited from Link
#assoc_object, #filter=, #initialize, #scope=
Methods inherited from Control
#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def action @action end |
#active ⇒ Object
Returns the value of attribute active.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def active @active end |
#badge_formula ⇒ Object
Returns the value of attribute badge_formula.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def badge_formula @badge_formula end |
#caption ⇒ Object
Returns the value of attribute caption.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def caption @caption end |
#controller ⇒ Object
Returns the value of attribute controller.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def controller @controller end |
#http_method ⇒ Object
Returns the value of attribute http_method.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def http_method @http_method end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def image @image end |
#object ⇒ Object
Returns the value of attribute object.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def object @object end |
#trail ⇒ Object
Returns the value of attribute trail.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def trail @trail end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/interview/navigation_item.rb', line 6 def url @url end |
Instance Method Details
#render ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/interview/navigation_item.rb', line 9 def render css_class = "level#{ancestors.count-1}" css_class += " active" if @active show_siblings = @active || siblings.any? { |sib| sib.active } link = Link.new(parent: self, url: @url, controller: @controller, object: @object, action: @action, http_method: @http_method, trail: @trail) badge = @badge_formula.call if @badge_formula unless badge.nil? or badge == 0 or badge == '' link.add_control(HtmlControl.new do |html| html.span badge, class: 'badge pull-right' end) end link.add_control(HtmlControl.new do |html| html.span '', class: "glyphicon glyphicon-#{@image}" if @image html.text! ' ' if @image and @caption html << @caption if @caption end) html = Builder::XmlMarkup.new html.li class: css_class do html << link.render end if show_siblings @controls.each do |c| html << c.render end end return html.target! end |