Class: DetailController

Inherits:
Shirka::Qt::MultipanelController show all
Defined in:
lib/troshka/detail/controller.rb

Instance Attribute Summary

Attributes inherited from Shirka::Controller

#app, #components, #data, #parent, #view

Instance Method Summary collapse

Methods inherited from Shirka::Controller

#add_component, #add_item, #initialize, #item_controller_class, #on_component_added, #on_component_adding, #view_class

Methods included from Shirka::Eventalk

#add_watcher, #fire, #forward, #watch, #watchers

Constructor Details

This class inherits a constructor from Shirka::Controller

Instance Method Details

#init(data) ⇒ Object



2
3
4
# File 'lib/troshka/detail/controller.rb', line 2

def init(data)
  add_item "", DetailPanelObjectController
end

#on_code_evaluated(e) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/troshka/detail/controller.rb', line 10

def on_code_evaluated(e)
  obj = e.msg[:obj]
  
  #controller_class = if obj.respond_to? :each
  #  DetailPanelEnumerableController
  #else
  #  DetailPanelController
  #end
  
  name = obj.class.ancestors
    .map{|i| "DetailPanel#{i}Controller"}
    .find {|i| Object.const_get i rescue false}

  add_item obj, Object.const_get(name) unless name.nil?
end

#on_starting(e) ⇒ Object



6
7
8
# File 'lib/troshka/detail/controller.rb', line 6

def on_starting(e)
  watch app.components[:editor]
end