Class: MultiView

Inherits:
Lapillus::Component show all
Defined in:
lib/lapillus/multiview.rb

Instance Attribute Summary collapse

Attributes inherited from Lapillus::Component

#behaviours, #identifier, #model, #property, #visible

Instance Method Summary collapse

Methods inherited from Lapillus::Component

#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage

Constructor Details

#initialize(id, views) ⇒ MultiView

Returns a new instance of MultiView.



11
12
13
14
15
16
# File 'lib/lapillus/multiview.rb', line 11

def initialize(id, views)
  super(id)
  @views = views
  views.each {|view| view.parent = self } #TODO: add test!
  @mode=views[0].identifier
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



10
11
12
# File 'lib/lapillus/multiview.rb', line 10

def mode
  @mode
end

Instance Method Details

#[](path) ⇒ Object

TODO: add test



42
43
44
# File 'lib/lapillus/multiview.rb', line 42

def [](path)
  current_view[path]
end

#component(identifier) ⇒ Object

TODO: add test



38
39
40
# File 'lib/lapillus/multiview.rb', line 38

def component(identifier)
  return current_view.component(identifier)
end

#current_view(id = mode) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/lapillus/multiview.rb', line 18

def current_view(id=mode)
  @views.each do |v|
    return v  if v.identifier == id
  end
  raise "view with identifier #{id} not found!"
  nil
end

#post(values) ⇒ Object

TODO: add test



34
35
36
# File 'lib/lapillus/multiview.rb', line 34

def post(values)  
  current_view.post(values)
end

#render_container(html) ⇒ Object



26
27
28
29
30
31
# File 'lib/lapillus/multiview.rb', line 26

def render_container(html)
  singleview = current_view
  result = singleview.render_container(html)
  render_behaviours(result)
  return result
end