Class: Interview::List

Inherits:
Control show all
Includes:
HasControls
Defined in:
lib/interview/list.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

#empty_messageObject

Returns the value of attribute empty_message.



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

def empty_message
  @empty_message
end

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/interview/list.rb', line 6

def object
  @object
end

#objectsObject

Returns the value of attribute objects.



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

def objects
  @objects
end

Instance Method Details

#renderObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/interview/list.rb', line 8

def render
  objects = @objects || find_attribute!(:objects)
  puts "objects: #{objects.size}"
  html = Builder::XmlMarkup.new
  objects.each do |object|
    @object = object
    @controls.each do |control| # todo: controls neu initialisieren?
      html << control.render
    end
  end
  if objects.empty? and @empty_message != :hide
    object = find_attribute!(:object)
    empty_message = @empty_message || "Keine #{object.class.human_name(count: 2)} vorhanden."
    html.p empty_message, class: 'text-center text-muted'
  end
  return html.target!
end