mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Performance and memory usage fixes (#2309)
* Use select and reject instead of partition.map * Sort adapters keys in place * Just select from options * Add changelog entry
This commit is contained in:
parent
22f2cb76dd
commit
209834dc49
@ -11,6 +11,7 @@ Fixes:
|
|||||||
- [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.
|
- [#2307](https://github.com/rails-api/active_model_serializers/pull/2307) Falsey attribute values should not be reevaluated.
|
||||||
|
|
||||||
Misc:
|
Misc:
|
||||||
|
- [#2309](https://github.com/rails-api/active_model_serializers/pull/2309) Performance and memory usage fixes
|
||||||
|
|
||||||
### [v0.10.8 (2018-11-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.7...v0.10.8)
|
### [v0.10.8 (2018-11-01)](https://github.com/rails-api/active_model_serializers/compare/v0.10.7...v0.10.8)
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ module ActiveModel
|
|||||||
delegate :collection?, to: :reflection
|
delegate :collection?, to: :reflection
|
||||||
|
|
||||||
def reflection_options
|
def reflection_options
|
||||||
@reflection_options ||= reflection.options.dup.reject { |k, _| !REFLECTION_OPTIONS.include?(k) }
|
@reflection_options ||= reflection.options.select { |k, _| REFLECTION_OPTIONS.include?(k) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def object
|
def object
|
||||||
|
|||||||
@ -37,7 +37,7 @@ module ActiveModelSerializers
|
|||||||
|
|
||||||
# @return [Array<Symbol>] list of adapter names
|
# @return [Array<Symbol>] list of adapter names
|
||||||
def adapters
|
def adapters
|
||||||
adapter_map.keys.sort
|
adapter_map.keys.sort!
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds an adapter 'klass' with 'name' to the 'adapter_map'
|
# Adds an adapter 'klass' with 'name' to the 'adapter_map'
|
||||||
|
|||||||
@ -16,8 +16,8 @@ module ActiveModelSerializers
|
|||||||
# @return the serializable_resource, ready for #as_json/#to_json/#serializable_hash.
|
# @return the serializable_resource, ready for #as_json/#to_json/#serializable_hash.
|
||||||
def initialize(resource, options = {})
|
def initialize(resource, options = {})
|
||||||
@resource = resource
|
@resource = resource
|
||||||
@adapter_opts, @serializer_opts =
|
@adapter_opts = options.select { |k, _| ADAPTER_OPTION_KEYS.include? k }
|
||||||
options.partition { |k, _| ADAPTER_OPTION_KEYS.include? k }.map { |h| Hash[h] }
|
@serializer_opts = options.reject { |k, _| ADAPTER_OPTION_KEYS.include? k }
|
||||||
end
|
end
|
||||||
|
|
||||||
def serialization_scope=(scope)
|
def serialization_scope=(scope)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user