Skip to content

Commit 0422a1e

Browse files
Swap out KeyTransform for CaseTransform (#1993)
* delete KeyTransform, use CaseTransform * added changelog
1 parent fca2d45 commit 0422a1e

File tree

7 files changed

+10
-379
lines changed

7 files changed

+10
-379
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Fixes:
1515
Misc:
1616

1717
- [#1984](https://github.com/rails-api/active_model_serializers/pull/1984) Make test attributes explicit. Test models have 'associations' support. (@bf4)
18+
- [#1993](https://github.com/rails-api/active_model_serializers/pull/1993) Swap out KeyTransform for CaseTransform gem for the possibility of native extension use (@NullVoxPopuli)
1819

1920
### [v0.10.3 (2016-11-21)](https://github.com/rails-api/active_model_serializers/compare/v0.10.2...v0.10.3)
2021

active_model_serializers.gemspec

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Gem::Specification.new do |spec|
4343
# 'thread_safe'
4444

4545
spec.add_runtime_dependency 'jsonapi', '0.1.1.beta2'
46+
spec.add_runtime_dependency 'case_transform', '>= 0.2'
4647

4748
spec.add_development_dependency 'activerecord', rails_versions
4849
# arel

lib/active_model_serializers/adapter/base.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'active_model_serializers/key_transform'
1+
require 'case_transform'
22

33
module ActiveModelSerializers
44
module Adapter
@@ -31,7 +31,7 @@ def self.transform(options)
3131
# @param options [Object] serializable resource options
3232
# @return [Symbol] the default transform for the adapter
3333
def self.transform_key_casing!(value, options)
34-
KeyTransform.send(transform(options), value)
34+
CaseTransform.send(transform(options), value)
3535
end
3636

3737
def self.cache_key

lib/active_model_serializers/adapter/json_api/deserialization.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def parse_relationships(relationships, options)
205205
# @api private
206206
def transform_keys(hash, options)
207207
transform = options[:key_transform] || :underscore
208-
KeyTransform.send(transform, hash)
208+
CaseTransform.send(transform, hash)
209209
end
210210
end
211211
end

lib/active_model_serializers/key_transform.rb

-74
This file was deleted.

0 commit comments

Comments
 (0)