Sha256: 0c71ed9db791c04493e4de5ee11624b7a83fae6283f9113c7dec5b9ae1894a02

Contents?: true

Size: 1.09 KB

Versions: 23

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

# :markup: markdown

module ActionController # :nodoc:
  module PermissionsPolicy
    extend ActiveSupport::Concern

    module ClassMethods
      # Overrides parts of the globally configured `Feature-Policy` header:
      #
      #     class PagesController < ApplicationController
      #       permissions_policy do |policy|
      #         policy.geolocation "https://example.com"
      #       end
      #     end
      #
      # Options can be passed similar to `before_action`. For example, pass `only:
      # :index` to override the header on the index action only:
      #
      #     class PagesController < ApplicationController
      #       permissions_policy(only: :index) do |policy|
      #         policy.camera :self
      #       end
      #     end
      #
      def permissions_policy(**options, &block)
        before_action(options) do
          if block_given?
            policy = request.permissions_policy.clone
            instance_exec(policy, &block)
            request.permissions_policy = policy
          end
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
actionpack-8.0.1 lib/action_controller/metal/permissions_policy.rb
actionpack-8.0.0.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.2.1 lib/action_controller/metal/permissions_policy.rb
actionpack-8.0.0 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.2 lib/action_controller/metal/permissions_policy.rb
actionpack-8.0.0.rc2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.1.2 lib/action_controller/metal/permissions_policy.rb
actionpack-8.0.0.rc1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.1.1 lib/action_controller/metal/permissions_policy.rb
actionpack-8.0.0.beta1 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha9 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha8 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha7 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha4 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha3 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha2 lib/action_controller/metal/permissions_policy.rb
omg-actionpack-8.0.0.alpha1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.0 lib/action_controller/metal/permissions_policy.rb
actionpack-7.2.0.rc1 lib/action_controller/metal/permissions_policy.rb