Class: Interview::MediaObject

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

#objectObject (readonly)

Returns the value of attribute object.



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

def object
  @object
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
36
37
38
39
40
41
42
# File 'lib/interview/media_object.rb', line 7

def render
  image_size = @image_size || :thumb
  object = find_attribute! :object
  @object = object
  html = Builder::XmlMarkup.new(indent: 2)
  html.div class: 'media' do
    @controls.first.html_class << 'pull-left'
    html << @controls.first.render
    html.div class: 'media-body' do
      @controls[1].html_class << 'media-heading' if @controls[1].respond_to? 'html_class'
      @controls[1..-1].each do |control|
        html << control.render
      end
    end
  end
          
  #   html.a class: 'pull-left', href: '#' do
  #     html << h.image_tag(object.send(@image_method.to_sym).url(image_size), class: 'media-object')
  #   end
  #   html.div class: 'media-body' do
  #     html.h4 object.send(@heading_method.to_sym), class: 'media-heading' if @heading_method
  #     @controls.each do |control|
  #       html << control.render
  #     end
  #     if @children_method
  #       object.send(@children_method).each do |child_object|
  #         @object = child_object
  #         media_object = MediaObject.new(parent: self, image_method: @image_method, heading_method: @heading_method, children_method: @children_method)
  #         media_object.add_controls(self.controls)
  #         html << media_object.render
  #       end
  #     end
  #   end
  # end
  return html.target!
end