Guest User

Untitled

a guest
Jun 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class ViewContext
  2. def initialize(*args)
  3. @_content_for = Hash.new
  4. end
  5.  
  6. def content_for(name, content, &block)
  7. content = capture(&block) if block_given?
  8. @_content_for[name] = content
  9. end
  10. end
  11.  
  12. class ActionController::Base
  13. def view_context
  14. ViewContext.new
  15. end
  16. end
  17.  
  18.  
  19. #####
  20. @controller = ActionController::Base.new
  21. @controller.view_context.content_for :foo, :bar
  22. @controller.view_context.instance_variable_get "@_content_for" # => {}
Add Comment
Please, Sign In to add comment