Class: Interview::List

Inherits:
Control show all
Defined in:
lib/interview/controls/list.rb

Instance Attribute Summary collapse

Attributes inherited from Control

#parent

Instance Method Summary collapse

Methods inherited from Control

#ancestors, #build_child, #build_with_params, #find_attribute, #find_attribute!, #initialize, #set_attributes, #set_defaults

Constructor Details

This class inherits a constructor from Interview::Control

Instance Attribute Details

#empty_messageObject

Returns the value of attribute empty_message.



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

def empty_message
  @empty_message
end

#objectObject

Returns the value of attribute object.



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

def object
  @object
end

#objectsObject

Returns the value of attribute objects.



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

def objects
  @objects
end

Instance Method Details

#build(b) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/interview/controls/list.rb', line 6

def build(b)
  objects = @objects || find_attribute!(:objects)
  objects.each do |object|
    @object = object
    yield if block_given?
  end
  if objects.empty? and @empty_message != :hide
    object = @object || find_attribute!(:object)
    empty_message = @empty_message || "Keine #{object.class.human_name(count: 2)} vorhanden." # todo
    b.text text: empty_message, style: 'p', html_class: 'text-center text-muted'
  end
end