Skip to content

Commit

Permalink
Active Support is required differently nowadays
Browse files Browse the repository at this point in the history
> In order to have the smallest default footprint possible, Active Support loads the minimum dependencies by default. It is broken in small pieces so that only the desired extensions can be loaded.

https://guides.rubyonrails.org/active_support_core_extensions.html#stand-alone-active-support

This was changed in Rails 3, released 2010-08-29.

- We're not using anything from `core_ext/module/introspection`
- We're not using blank or present from `core_ext/object/blank`
- We're not using `autoload`
  • Loading branch information
Burgestrand committed Oct 10, 2024
1 parent 66cf520 commit b44dd15
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Changed

- Using `permit` matcher without a surrouding `permissions` block now raises a useful error. (#834)
- Explicitly require less of `active_support` (#834)

## 2.4.0 (2024-08-26)

Expand Down
7 changes: 2 additions & 5 deletions lib/pundit.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# frozen_string_literal: true

require "active_support"

require "pundit/version"
require "pundit/policy_finder"
require "active_support/concern"
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/module/introspection"
require "active_support/dependencies/autoload"
require "pundit/authorization"
require "pundit/context"
require "pundit/cache_store/null_store"
Expand Down
3 changes: 3 additions & 0 deletions lib/pundit/policy_finder.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

# String#safe_constantize, String#demodulize, String#underscore, String#camelize
require "active_support/core_ext/string/inflections"

module Pundit
# Finds policy and scope classes for given object.
# @api public
Expand Down
3 changes: 3 additions & 0 deletions lib/pundit/rspec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

# Array#to_sentence
require "active_support/core_ext/array/conversions"

module Pundit
module RSpec
module Matchers
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

require "pundit"
require "pundit/rspec"
require "active_support"
require "active_model"
require "active_model/naming"

# Load all supporting files: models, policies, etc.
require "zeitwerk"
Expand All @@ -20,3 +19,5 @@
loader.push_dir(File.expand_path("support/lib", __dir__))
loader.setup
loader.eager_load

puts $LOADED_FEATURES.grep(%r{active_support/core_ext}).join("\n")

0 comments on commit b44dd15

Please sign in to comment.