Class: Wee::RootComponent
- Defined in:
- lib/wee/root_component.rb
Overview
A RootComponent has a special instanciate class method that makes it more comfortable for root components.
Direct Known Subclasses
Constant Summary
Constants inherited from Component
Class Method Summary collapse
-
.external_resources ⇒ Object
Returns an array of ExternalResource objects required for this RootComponent.
- .instanciate(*args, &block) ⇒ Object
- .run(*params, &block) ⇒ Object
Instance Method Summary collapse
Methods inherited from Component
#add_decoration, #children, #choose_from, #confirm, #decoration, #decoration=, depends, #each_decoration, #find_decoration, #inform, #initialize, #process_callbacks, #remove_decoration, #remove_decoration_if, #render, #state
Methods inherited from Presenter
#process_callbacks, #render, #render!, #renderer_class, #state
Constructor Details
This class inherits a constructor from Wee::Component
Class Method Details
.external_resources ⇒ Object
Returns an array of ExternalResource objects required for this RootComponent.
24 25 26 27 |
# File 'lib/wee/root_component.rb', line 24 def self.external_resources self.depends.flatten.select {|cls| cls <= Wee::ExternalResource }.uniq. map {|cls| cls.new } end |
.instanciate(*args, &block) ⇒ Object
37 38 39 40 41 |
# File 'lib/wee/root_component.rb', line 37 def self.instanciate(*args, &block) obj = new(*args, &block) obj.add_decoration Wee::PageDecoration.new(obj.title, obj.stylesheets, obj.javascripts) return obj end |
Instance Method Details
#javascripts ⇒ Object
33 34 35 |
# File 'lib/wee/root_component.rb', line 33 def javascripts self.class.external_resources.map {|ext_res| ext_res.javascripts}.flatten end |
#stylesheets ⇒ Object
29 30 31 |
# File 'lib/wee/root_component.rb', line 29 def stylesheets self.class.external_resources.map {|ext_res| ext_res.stylesheets}.flatten end |
#title ⇒ Object
16 17 18 |
# File 'lib/wee/root_component.rb', line 16 def title self.class.name.to_s end |