class Rack::Unpoly::Inspector

Easily inspect the Unpoly environment of the current request. Inspectors are not normally instantiated by users, but accessed through +env+ or one of the convenience wrappers for Roda and Sinatra.

Public Instance Methods

any_target?(tested_target) click to toggle source

Determine if the provided target is the current target for a successful or failed request.

# File lib/rack/unpoly/inspector.rb, line 50
def any_target?(tested_target)
  target?(tested_target) || fail_target?(tested_target)
end
fail_target() click to toggle source

The CSS selector for the fragment Unpoly will update if the request fails. Requires Unpoly >= 0.50

# File lib/rack/unpoly/inspector.rb, line 39
def fail_target
  get_header("HTTP_X_UP_FAIL_TARGET")
end
fail_target?(tested_target) click to toggle source

Determine if the provided target is the current target for a failed request. Requires Unpoly >= 0.50

# File lib/rack/unpoly/inspector.rb, line 45
def fail_target?(tested_target)
  query_target(fail_target, tested_target)
end
set_title(response, new_title) click to toggle source

Set the page title.

# File lib/rack/unpoly/inspector.rb, line 55
def set_title(response, new_title)
  response.headers["X-Up-Title"] = new_title
end
target() click to toggle source

The actual target as requested by Unpoly.

# File lib/rack/unpoly/inspector.rb, line 33
def target
  get_header("HTTP_X_UP_TARGET")
end
target?(tested_target) click to toggle source

Identify if the tested_target will match the actual target requested.

# File lib/rack/unpoly/inspector.rb, line 28
def target?(tested_target)
  query_target(target, tested_target)
end
unpoly?() click to toggle source

Determine if this is an Unpoly request.

# File lib/rack/unpoly/inspector.rb, line 22
def unpoly?
  target.to_s.strip != ""
end
Also aliased as: up?
up?()
Alias for: unpoly?
validate?() click to toggle source

Determine if this is a validate request.

# File lib/rack/unpoly/inspector.rb, line 60
def validate?
  validate_name.to_s.strip != ""
end
validate_name() click to toggle source

The name attribute of the form field that triggered the validation.

# File lib/rack/unpoly/inspector.rb, line 66
def validate_name
  get_header("HTTP_X_UP_VALIDATE")
end