Sha256: 32ac3640b3b16b2dd3d9dc3d978e1ff93ac7192f397f7e38f89c288d29c05f37

Contents?: true

Size: 1.06 KB

Versions: 16

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

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
      # <tt>only: :index</tt> 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

16 entries across 16 versions & 3 rubygems

Version Path
actionpack-7.1.5 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.4.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.4.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.4 lib/action_controller/metal/permissions_policy.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionpack-7.1.3.4/lib/action_controller/metal/permissions_policy.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/actionpack-7.1.3.4/lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.3.4 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.3.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.3.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.3 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.0 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.0.rc2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.0.rc1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.1.0.beta1 lib/action_controller/metal/permissions_policy.rb