Class: Sirens::ModuleBrowser

Inherits:
Component show all
Defined in:
lib/sirens/browsers/module_browser.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Component

#build, #create_view, #initialize, #main_child_component, #on_component_added, #open

Methods inherited from AbstractComponent

#add_all_components, #add_component, #child_components, #create_view, #initialize, #model, #on_component_added, #on_model_changed, open, #props, #remove_component_at, #remove_last_component, #set_model, #set_props, #view

Constructor Details

This class inherits a constructor from Sirens::Component

Class Method Details

.open_on(klass: nil) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/sirens/browsers/module_browser.rb', line 5

def self.open_on(klass: nil)
    self.open.tap { |browser|
        if klass.kind_of?(Class)
            browser.model.select_class(klass)
        else
            browser.model.select_namespace(namespace)
        end
    }
end

Instance Method Details

#default_modelObject

Model



17
18
19
# File 'lib/sirens/browsers/module_browser.rb', line 17

def default_model()
    ModuleBrowserModel.new
end

#render_with(layout) ⇒ Object

Building



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sirens/browsers/module_browser.rb', line 23

def render_with(layout)
    browser_model = model

    layout.render do |component|

        window do

            styles title: 'Namespace Browser',
                width: 900,
                height: 400

            vertical_splitter do

                horizontal_splitter do

                    styles splitter_proportion: 1.0/2.0

                    component NamespacesList.new(
                        model: browser_model.namespaces,
                        splitter_proportion: 1.0/5.0
                    )

                    component ModulesList.new(
                        model: browser_model.modules,
                        splitter_proportion: 1.0/5.0,
                    )

                    component ClassBrowser.new(
                        model: browser_model,
                        splitter_proportion: 1.0/5.0
                    )
                end

                component MethodSourceCode.new(
                    model: browser_model.method_source_code,
                    splitter_proportion: 1.0/2.0
                )

            end

        end
    end
end