Sha256: b670bceda5ebdc49f213a8d3744e50d88fc29ccb0f892b1516de5371e0372b43

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 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
            yield policy
            request.permissions_policy = policy
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
actionpack-7.0.8.7 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.8.6 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.8.5 lib/action_controller/metal/permissions_policy.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/actionpack-7.0.8.4/lib/action_controller/metal/permissions_policy.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_controller/metal/permissions_policy.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_controller/metal/permissions_policy.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/actionpack-7.0.5.1/lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.8.4 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.8.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.8 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.7.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.7.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.7 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.6 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.5.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.5 lib/action_controller/metal/permissions_policy.rb