Class: Interview::Actionbar

Inherits:
Control
  • Object
show all
Includes:
HasControls
Defined in:
lib/interview/actionbar.rb

Instance Attribute Summary collapse

Attributes included from HasControls

#controls

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods included from HasControls

#add_control, #add_controls, included, #initialize, #siblings

Methods inherited from Control

#ancestors, build, definition, #find_attribute, #find_attribute!, inherited, #initialize, #set_attributes, #set_defaults

Instance Attribute Details

#iconObject

Returns the value of attribute icon.



5
6
7
# File 'lib/interview/actionbar.rb', line 5

def icon
  @icon
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/interview/actionbar.rb', line 5

def title
  @title
end

Instance Method Details

#renderObject



7
8
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
# File 'lib/interview/actionbar.rb', line 7

def render
  title = @title || find_attribute(:title)
  icon = @icon
  if icon == :polymorphic
    object = find_attribute! :object
    icon = object.icon
  end
  
  html = Builder::XmlMarkup.new
  html.div class: 'clearfix' do
    unless @controls.empty?
      html.ul class: 'list-inline pull-right' do
        @controls.each do |control|
          html.li do
            html << control.render
          end
        end
      end
    end
    if title
      html.p class: 'h3' do
        html.span '', class: icon if icon
        html.text! ' ' if icon
        html.text! title
      end
    end
  end
  return html.target!
end