File tree Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Expand file tree Collapse file tree 4 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - (#386 )[ https://github.com/JsonApiClient/json_api_client/pull/386 ] - use HashWithIndifferentAccess
6
+
5
7
## 1.18.0
6
8
- [ #372 ] ( https://github.com/JsonApiClient/json_api_client/pull/372 ) - Fix handling of dashed-types associations correctly
7
9
Original file line number Diff line number Diff line change @@ -67,11 +67,11 @@ def last
67
67
end
68
68
69
69
def build ( attrs = { } )
70
- klass . new @path_params . merge ( attrs . symbolize_keys )
70
+ klass . new @path_params . merge ( attrs . with_indifferent_access )
71
71
end
72
72
73
73
def create ( attrs = { } )
74
- klass . create @path_params . merge ( attrs . symbolize_keys )
74
+ klass . create @path_params . merge ( attrs . with_indifferent_access )
75
75
end
76
76
77
77
def params
Original file line number Diff line number Diff line change @@ -348,7 +348,7 @@ def _build_connection(rebuild = false)
348
348
#
349
349
# @param params [Hash] Attributes, links, and relationships
350
350
def initialize ( params = { } )
351
- params = params . symbolize_keys
351
+ params = params . with_indifferent_access
352
352
@persisted = nil
353
353
@destroyed = nil
354
354
self . links = self . class . linker . new ( params . delete ( :links ) || { } )
@@ -538,7 +538,7 @@ def reset_request_select!(*resource_types)
538
538
end
539
539
540
540
def path_attributes
541
- _belongs_to_params . merge attributes . slice ( self . class . primary_key ) . symbolize_keys
541
+ _belongs_to_params . merge attributes . slice ( self . class . primary_key ) . with_indifferent_access
542
542
end
543
543
544
544
protected
Original file line number Diff line number Diff line change @@ -308,7 +308,8 @@ def test_build_propagate_only_path_params
308
308
query = ArticleNested . where ( author_id : '123' , name : 'John' )
309
309
record = query . build
310
310
assert_equal [ ] , record . changed
311
- assert_equal ( { author_id : '123' } , record . __belongs_to_params )
311
+ assert_equal ( record . __belongs_to_params [ :author_id ] , '123' )
312
+ assert_equal ( record . __belongs_to_params [ 'author_id' ] , '123' )
312
313
assert_equal '123' , record . author_id
313
314
assert_equal [ ] , record . relationships . changed
314
315
end
You can’t perform that action at this time.
0 commit comments