Module: Apotomo::WidgetShortcuts
- Included in:
- Rails::ControllerMethods, TestCase, Widget
- Defined in:
- lib/apotomo/widget_shortcuts.rb
Overview
Shortcut methods for creating widget trees.
Instance Method Summary collapse
-
#widget(prefix, *args) ⇒ Object
Shortcut for creating an instance of
class_name+"_widget"
namedid
.
Instance Method Details
#widget(prefix, *args) ⇒ Object
Shortcut for creating an instance of class_name+"_widget"
named id
. Yields self.
Example:
(:comments)
will create a CommentsWidget
with id :comments.
(:comments, 'post-comments', :user => current_user)
sets id to ‘posts_comments’ and #options to the hash.
You can also use namespaces.
('jquery/tabs', 'panel')
19 20 21 22 23 24 25 26 |
# File 'lib/apotomo/widget_shortcuts.rb', line 19 def (prefix, *args) = args. id = args.shift || prefix constant_for(prefix).new(parent_controller, id, ).tap do |object| yield object if block_given? end end |