class Blade::RackAdapter
Attributes
env[R]
request[R]
Public Class Methods
new()
click to toggle source
# File lib/blade/rack/adapter.rb, line 11 def initialize Blade.initialize! end
Public Instance Methods
call(env)
click to toggle source
# File lib/blade/rack/adapter.rb, line 15 def call(env) @env = env @request = Rack::Request.new(env) route = find_route(request.path_info) base_path, action = route.values_at(:base_path, :action) rewrite_path!(base_path) send(action[:to]) end
environment()
click to toggle source
# File lib/blade/rack/adapter.rb, line 46 def environment Blade::Assets.environment.call(env) end
index()
click to toggle source
# File lib/blade/rack/adapter.rb, line 27 def index request.path_info = "/blade/index.html" response = environment response = add_session_cookie(response) if needs_session_cookie? response.to_a end
redirect_to_index()
click to toggle source
# File lib/blade/rack/adapter.rb, line 34 def redirect_to_index Rack::Response.new.tap do |response| path = request.path path = path + "/" unless path.last == "/" response.redirect(path) end.to_a end
websocket()
click to toggle source
# File lib/blade/rack/adapter.rb, line 42 def websocket faye_adapter.call(env) end
Private Instance Methods
faye_adapter()
click to toggle source
# File lib/blade/rack/adapter.rb, line 70 def faye_adapter @faye_adapter ||= Faye::RackAdapter.new(mount: "/", timeout: 25) end
rewrite_path!(path = nil)
click to toggle source
# File lib/blade/rack/adapter.rb, line 64 def rewrite_path!(path = nil) return if path.nil? request.path_info = request.path_info.sub(path, "").presence || "/" request.script_name = request.script_name + path end