class ProgressiveRender::Rack::RequestHandler
Wraps a given rack request to determine what sort of request we're dealing with and what specific fragment the request is for when it's a progressive request.
Constants
- FRAGMENT_KEY
Public Class Methods
new(request)
click to toggle source
# File lib/progressive_render/rack/request_handler.rb, line 11 def initialize(request) @request = request end
Public Instance Methods
fragment_name()
click to toggle source
# File lib/progressive_render/rack/request_handler.rb, line 19 def fragment_name @request.GET[FRAGMENT_KEY] end
load_path(fragment_name)
click to toggle source
# File lib/progressive_render/rack/request_handler.rb, line 27 def load_path(fragment_name) return nil unless main_load? # Ensure we get a fresh copy of the request and aren't modifying it query = @request.GET.clone query[FRAGMENT_KEY] = fragment_name URI::HTTP.build(path: @request.path, query: ::Rack::Utils.build_nested_query(query)).request_uri end
main_load?()
click to toggle source
# File lib/progressive_render/rack/request_handler.rb, line 15 def main_load? fragment_name.nil? || fragment_name == '' end
should_render_fragment?(user_fragment_name)
click to toggle source
# File lib/progressive_render/rack/request_handler.rb, line 23 def should_render_fragment?(user_fragment_name) !main_load? && fragment_name == user_fragment_name end