Apotomo support for builders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in lib/apotomo/widget.rb | |
# This comes redundant with Cells internals, but this is due to what may be a flaw in current Apotomo's design, | |
# which bypass Cells workflow (render_cell_for) and hook directly into AbstractController::Rendering #render_state | |
# Renders the +widget+ (instance or id). | |
def render_widget(widget_id, state=:display, *args) | |
if widget_id.kind_of?(Widget) | |
widget = widget_id | |
else | |
widget = find_widget(widget_id) or raise "Couldn't render non-existent widget `#{widget_id}`" | |
end | |
# *** added *** | |
# Ensure the proper widget class is used in case the widget delegates to some other fellow | |
target_class = self.class.build_class_for(parent_controller, widget.class, args.first) | |
if widget.class != target_class | |
widget = target_class.new(parent_controller, widget_id, args.first) | |
end | |
# *** /added *** | |
widget.invoke(state, *args) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment