mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +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.
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ module ActiveModel
|
||||
delegate :collection?, to: :reflection
|
||||
|
||||
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
|
||||
|
||||
def object
|
||||
|
||||
@ -37,7 +37,7 @@ module ActiveModelSerializers
|
||||
|
||||
# @return [Array<Symbol>] list of adapter names
|
||||
def adapters
|
||||
adapter_map.keys.sort
|
||||
adapter_map.keys.sort!
|
||||
end
|
||||
|
||||
# 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.
|
||||
def initialize(resource, options = {})
|
||||
@resource = resource
|
||||
@adapter_opts, @serializer_opts =
|
||||
options.partition { |k, _| ADAPTER_OPTION_KEYS.include? k }.map { |h| Hash[h] }
|
||||
@adapter_opts = options.select { |k, _| ADAPTER_OPTION_KEYS.include? k }
|
||||
@serializer_opts = options.reject { |k, _| ADAPTER_OPTION_KEYS.include? k }
|
||||
end
|
||||
|
||||
def serialization_scope=(scope)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user