mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Correct minor typos
This commit is contained in:
parent
80e75202ea
commit
63317699f3
@ -116,7 +116,7 @@ module ActiveModel
|
|||||||
|
|
||||||
# @api private
|
# @api private
|
||||||
# Used by FragmentCache on the CachedSerializer
|
# Used by FragmentCache on the CachedSerializer
|
||||||
# to call attribute methods on the fragmented cached serializer
|
# to call attribute methods on the fragmented cached serializer.
|
||||||
def self.fragmented(serializer)
|
def self.fragmented(serializer)
|
||||||
self._fragmented = serializer
|
self._fragmented = serializer
|
||||||
end
|
end
|
||||||
@ -174,7 +174,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Used to cache serializer name => serializer class
|
# Used to cache serializer name => serializer class
|
||||||
# when looked up by Serializer.get_serializer_for
|
# when looked up by Serializer.get_serializer_for.
|
||||||
def self.serializers_cache
|
def self.serializers_cache
|
||||||
@serializers_cache ||= ThreadSafe::Cache.new
|
@serializers_cache ||= ThreadSafe::Cache.new
|
||||||
end
|
end
|
||||||
@ -215,8 +215,8 @@ module ActiveModel
|
|||||||
attr_accessor :object, :root, :scope
|
attr_accessor :object, :root, :scope
|
||||||
|
|
||||||
# `scope_name` is set as :current_user by default in the controller.
|
# `scope_name` is set as :current_user by default in the controller.
|
||||||
# If the instance does not have a method nameed `scope_name`, it
|
# If the instance does not have a method named `scope_name`, it
|
||||||
# defines the method so that calls the +scope+.
|
# defines the method so that it calls the +scope+.
|
||||||
def initialize(object, options = {})
|
def initialize(object, options = {})
|
||||||
self.object = object
|
self.object = object
|
||||||
self.instance_options = options
|
self.instance_options = options
|
||||||
@ -231,7 +231,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Used by adapter as resource root
|
# Used by adapter as resource root.
|
||||||
def json_key
|
def json_key
|
||||||
root || object.class.model_name.to_s.underscore
|
root || object.class.model_name.to_s.underscore
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,12 +12,12 @@ module ActiveModel
|
|||||||
|
|
||||||
# TODO: Use Serializable::Resource
|
# TODO: Use Serializable::Resource
|
||||||
# TODO: call +constantize+ less
|
# TODO: call +constantize+ less
|
||||||
# 1. Create a CachedSerializer and NonCachedSerializer from the serializer class.
|
# 1. Create a CachedSerializer and NonCachedSerializer from the serializer class
|
||||||
# 2. Serialize the above two with the given adapter.
|
# 2. Serialize the above two with the given adapter
|
||||||
# 3. Pass their serializations to the adapter +::fragment_cache+.
|
# 3. Pass their serializations to the adapter +::fragment_cache+
|
||||||
def fetch
|
def fetch
|
||||||
klass = serializer.class
|
klass = serializer.class
|
||||||
# It will split the serializer into two, one that will be cached and other wont
|
# It will split the serializer into two, one that will be cached and one that will not
|
||||||
serializers = fragment_serializer(serializer.object.class.name, klass)
|
serializers = fragment_serializer(serializer.object.class.name, klass)
|
||||||
|
|
||||||
# Instantiate both serializers
|
# Instantiate both serializers
|
||||||
@ -41,9 +41,9 @@ module ActiveModel
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Given a serializer class and a hash of its cached and non0cached serializers
|
# Given a serializer class and a hash of its cached and non-cached serializers
|
||||||
# 1. Determine cached attributes from serializer class options.
|
# 1. Determine cached attributes from serializer class options
|
||||||
# 2. Add cached attributes to cached Serializer.
|
# 2. Add cached attributes to cached Serializer
|
||||||
# 3. Add non-cached attributes to non-cached Serializer
|
# 3. Add non-cached attributes to non-cached Serializer
|
||||||
def cached_attributes(klass, serializers)
|
def cached_attributes(klass, serializers)
|
||||||
attributes = serializer.class._attributes
|
attributes = serializer.class._attributes
|
||||||
@ -66,8 +66,8 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Given a resource name and its serializer's class
|
# Given a resource name and its serializer's class
|
||||||
# 1. Dyanmically creates a CachedSerializer and NonCachedSerializer
|
# 1. Dyanmically creates a CachedSerializer and NonCachedSerializer
|
||||||
# for a given class 'name'.
|
# for a given class 'name'
|
||||||
# 2. Call
|
# 2. Call
|
||||||
# CachedSerializer.cache(serializer._cache_options)
|
# CachedSerializer.cache(serializer._cache_options)
|
||||||
# CachedSerializer.fragmented(serializer)
|
# CachedSerializer.fragmented(serializer)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user