Skip to content

Instantly share code, notes, and snippets.

@pascalbetz
Created January 5, 2016 21:08
Show Gist options
  • Save pascalbetz/a431457425bef4c6e550 to your computer and use it in GitHub Desktop.
Save pascalbetz/a431457425bef4c6e550 to your computer and use it in GitHub Desktop.
## View Hierarchy
Web::Views::Home::WithPartial
Web::Views::Home::AnotherSubclass < Web::Views::Home::WithPartial
## Add some debug code
# in view/rendering/registry.rb
def initialize(*args)
puts "Creating registry #{object_id} for #{args}"
super(*args)
end
def resolve(context)
puts "resolving with #{object_id} (#{self.class})"
view, template = @registry.fetch(format(context)) { @registry[DEFAULT_FORMAT] }
view.new(template, context)
end
# in view/rendering/layout_registry.rb
def resolve(context)
puts "resolving with #{object_id} (#{self.class})"
@registry.fetch(format(context)) { NullTemplate.new }
end
# start the server
ruby-2.2.0 partial-test$ RACK_ENV=development puma --threads 4:4 --port 2300 --preload --quiet
Puma starting in single mode...
* Version 2.14.0 (ruby 2.2.0-p0), codename: Fuchsia Friday
* Min threads: 4, max threads: 4
* Environment: development
Creating registry 70346904596500 for [Web::Views::Home::WithPartial]
* Listening on tcp://0.0.0.0:2300
Use Ctrl-C to stop
# make the request to subclass view and observe lines added to the console where server was started
Creating registry 70346905675720 for [Web::Views::Home::AnotherSubclass]
resolving with 70346905675720 (Lotus::View::Rendering::Registry)
resolving with 70346918282200 (Lotus::View::Rendering::LayoutRegistry)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment