mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Rubocop autocorrect
This commit is contained in:
committed by
Yohan Robert
parent
ec36ab7f60
commit
a26d3e4425
@@ -33,7 +33,7 @@ module ActiveModel
|
||||
def adapter
|
||||
@adapter ||= ActiveModelSerializers::Adapter.create(serializer_instance, adapter_opts)
|
||||
end
|
||||
alias_method :adapter_instance, :adapter
|
||||
alias adapter_instance adapter
|
||||
|
||||
def serializer_instance
|
||||
@serializer_instance ||= serializer.new(resource, serializer_opts)
|
||||
@@ -54,7 +54,7 @@ module ActiveModel
|
||||
@serializer
|
||||
end
|
||||
end
|
||||
alias_method :serializer_class, :serializer
|
||||
alias serializer_class serializer
|
||||
|
||||
# True when no explicit adapter given, or explicit appear is truthy (non-nil)
|
||||
# False when explicit adapter is falsy (nil or false)
|
||||
@@ -63,7 +63,7 @@ module ActiveModel
|
||||
end
|
||||
|
||||
def serializer?
|
||||
use_adapter? && !!(serializer)
|
||||
use_adapter? && !!serializer
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -92,7 +92,7 @@ module ActiveModel
|
||||
self._cache_key = options.delete(:key)
|
||||
self._cache_only = options.delete(:only)
|
||||
self._cache_except = options.delete(:except)
|
||||
self._cache_options = (options.empty?) ? nil : options
|
||||
self._cache_options = options.empty? ? nil : options
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module ActiveModel
|
||||
class Serializer
|
||||
VERSION = '0.10.0.rc4'
|
||||
VERSION = '0.10.0.rc4'.freeze
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module ActiveModelSerializers
|
||||
module Adapter
|
||||
UnknownAdapterError = Class.new(ArgumentError)
|
||||
ADAPTER_MAP = {}
|
||||
ADAPTER_MAP = {}.freeze
|
||||
private_constant :ADAPTER_MAP if defined?(private_constant)
|
||||
require 'active_model_serializers/adapter/fragment_cache'
|
||||
require 'active_model_serializers/adapter/cached_serializer'
|
||||
@@ -49,7 +49,7 @@ module ActiveModelSerializers
|
||||
# 'Json' will both register as 'json'.
|
||||
def register(name, klass = name)
|
||||
name = name.to_s.gsub(/\AActiveModelSerializers::Adapter::/, ''.freeze)
|
||||
adapter_map.update(name.underscore => klass)
|
||||
adapter_map[name.underscore] = klass
|
||||
self
|
||||
end
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ module ActiveModelSerializers
|
||||
def object_cache_key
|
||||
object_time_safe = @cached_serializer.object.updated_at
|
||||
object_time_safe = object_time_safe.strftime('%Y%m%d%H%M%S%9N') if object_time_safe.respond_to?(:strftime)
|
||||
(@klass._cache_key) ? "#{@klass._cache_key}/#{@cached_serializer.object.id}-#{object_time_safe}" : @cached_serializer.object.cache_key
|
||||
@klass._cache_key ? "#{@klass._cache_key}/#{@cached_serializer.object.id}-#{object_time_safe}" : @cached_serializer.object.cache_key
|
||||
end
|
||||
|
||||
# find all cache_key for the collection_serializer
|
||||
|
||||
@@ -46,7 +46,7 @@ module ActiveModelSerializers
|
||||
# 3. Add non-cached attributes to non-cached Serializer
|
||||
def cached_attributes(klass, serializers)
|
||||
attributes = serializer.class._attributes
|
||||
cached_attributes = (klass._cache_only) ? klass._cache_only : attributes.reject { |attr| klass._cache_except.include?(attr) }
|
||||
cached_attributes = klass._cache_only ? klass._cache_only : attributes.reject { |attr| klass._cache_except.include?(attr) }
|
||||
non_cached_attributes = attributes - cached_attributes
|
||||
|
||||
cached_attributes.each do |attribute|
|
||||
|
||||
@@ -188,7 +188,7 @@ module ActiveModelSerializers
|
||||
end
|
||||
|
||||
polymorphic = (options[:polymorphic] || []).include?(assoc_name.to_sym)
|
||||
hash.merge!("#{prefix_key}_type".to_sym => assoc_data['type']) if polymorphic
|
||||
hash["#{prefix_key}_type".to_sym] = assoc_data['type'] if polymorphic
|
||||
|
||||
hash
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module ActiveModelSerializers
|
||||
no_root_cache = cached_hash.delete_if { |key, _value| key == core_cached[0] }
|
||||
no_root_non_cache = non_cached_hash.delete_if { |key, _value| key == core_non_cached[0] }
|
||||
cached_resource = (core_cached[1]) ? core_cached[1].deep_merge(core_non_cached[1]) : core_non_cached[1]
|
||||
hash = (root) ? { root => cached_resource } : cached_resource
|
||||
hash = root ? { root => cached_resource } : cached_resource
|
||||
|
||||
hash.deep_merge no_root_non_cache.deep_merge no_root_cache
|
||||
end
|
||||
|
||||
@@ -33,7 +33,7 @@ module ActiveModelSerializers
|
||||
alias_method old, name
|
||||
class_eval do
|
||||
define_method(name) do |*args, &block|
|
||||
target = self.is_a?(Module) ? "#{self}." : "#{self.class}#"
|
||||
target = is_a?(Module) ? "#{self}." : "#{self.class}#"
|
||||
msg = ["NOTE: #{target}#{name} is deprecated",
|
||||
replacement == :none ? ' with no replacement' : "; use #{replacement} instead",
|
||||
"\n#{target}#{name} called from #{ActiveModelSerializers.location_of_caller.join(":")}"
|
||||
|
||||
Reference in New Issue
Block a user