Skip to content

Commit e1576b2

Browse files
takaokoujiclaude
andcommitted
Make apply_filters public for 0.9.x backward compatibility
In 0.9.x, apply_filters was a public method that could be called from outside the resource class. In the current version, it was moved to the protected section. This change restores public accessibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c216d09 commit e1576b2

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

lib/jsonapi/active_relation_resource.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ def apply_filters(records, filters, options = {})
859859

860860
records
861861
end
862+
public :apply_filters # Public for 0.9.x backward compatibility
862863

863864
def get_aliased_field(path_with_field, join_manager)
864865
path = JSONAPI::Path.new(resource_klass: self, path_string: path_with_field)

test/unit/resource/backward_compatibility_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
require File.expand_path('../../../test_helper', __FILE__)
22

3+
# Tests for apply_filters public accessibility (0.9.x compatibility)
4+
class ApplyFiltersAccessibilityTest < ActiveSupport::TestCase
5+
def test_apply_filters_is_publicly_accessible
6+
# In 0.9.x, apply_filters was public and could be called from outside
7+
# Verify it's accessible as a public method
8+
assert PostResource.respond_to?(:apply_filters, false),
9+
"apply_filters should be a public class method for 0.9.x compatibility"
10+
end
11+
12+
def test_apply_filters_can_be_called_externally
13+
# Verify apply_filters can be called from outside the class
14+
records = Post.all
15+
filters = {}
16+
17+
# This should not raise NoMethodError
18+
result = PostResource.apply_filters(records, filters)
19+
20+
assert_kind_of ActiveRecord::Relation, result
21+
end
22+
end
23+
324
# Tests for ResourceSetOperationResult backward compatibility
425
class ResourceSetOperationResultBackwardCompatibilityTest < ActiveSupport::TestCase
526
def setup

0 commit comments

Comments
 (0)