Module: Apotomo::WidgetShortcuts
- Included in:
- Rails::ControllerMethods, TestCase, Widget
- Defined in:
- lib/apotomo/widget_shortcuts.rb
Overview
Create widget trees using the #widget DSL.
Defined Under Namespace
Modules: DSL Classes: FactoryProxy
Instance Method Summary collapse
-
#widget(*args, &block) ⇒ Object
Shortcut for creating an instance of
class_name+"_widget"
namedid
.
Instance Method Details
#widget(*args, &block) ⇒ Object
Shortcut for creating an instance of class_name+"_widget"
named id
. Yields self. Note that this creates a proxy object, only. The actual widget is built not until you added it, e.g. using #<<.
Example:
root << (:comments)
will create a CommentsWidget
with id :comments attached to root
.
(:comments, 'post-comments', :user => current_user)
sets id to ‘posts_comments’ and #options to the hash.
You can also use namespaces.
('jquery/tabs', 'panel')
Add a block if you need to grab the created widget right away.
root << (:comments) do |comments|
comments.markdown!
end
Using #widget is just a shortcut, you can always use the constructor as well.
CommentsWidget.new(root, :comments)
31 32 33 |
# File 'lib/apotomo/widget_shortcuts.rb', line 31 def (*args, &block) FactoryProxy.new(*args, &block) end |