class Unpoly::Rails::Change

This object allows the server to inspect the current request for Unpoly-related concerns such as “is this a page fragment update?”.

Available through the `#up` method in all controllers, helpers and views.

Public Class Methods

new(controller) click to toggle source
# File lib/unpoly/rails/change.rb, line 12
def initialize(controller)
  @controller = controller
end

Public Instance Methods

unknown() click to toggle source

Returns the version of Unpoly running in the browser that made the request.

# File lib/unpoly/rails/change.rb, line 46
memoize def version
unpoly?()
Alias for: up?
up?() click to toggle source

Returns whether the current request is an [page fragment update](unpoly.com/up.replace) triggered by an Unpoly frontend.

# File lib/unpoly/rails/change.rb, line 34
def up?
  # This will eventually just check for the X-Up-Version header.
  # Just in case a user still has an older version of Unpoly running on the frontend,
  # we also check for the X-Up-Target header.
  version.present? || target.present?
end
Also aliased as: unpoly?