active_model_serializers
https://github.com/rails-api/active_model_serializers
Ruby
ActiveModel::Serializer implementation and Rails hooks
ActiveModel::Serializer::Caching#fetch_fragment_cache
1. Create a CachedSerializer and NonCachedSerializer from the serializer class
2. Serialize the above two with the given adapter
3. Pass their serializations to the adapter +::fragment_cache+
It will split the serializer into two, one that will be cached and one that will not
Given a resource name
1. Dynamically creates a CachedSerializer and NonCachedSerializer
for a given class 'name'
2. Call
CachedSerializer.cache(serializer._cache_options)
CachedSerializer.fragmented(serializer)
NonCachedSerializer.cache(serializer._cache_options)
3. Build a hash keyed to the +cached+ and +non_cached+ serializers
4. Call +cached_attributes+ on the serializer class and the above hash
5. Return the hash
Given a hash of its cached and non-cached serializers
1. Determine cached attributes from serializer class options
2. Add cached attributes to cached Serializer
3. Add non-cached attributes to non-cached SerializerEdit
git clone [email protected]:rails-api/active_model_serializers.git
cd active_model_serializers
open lib/active_model/serializer/caching.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-ActiveModel--Serializer--Caching-fetch_fragment_cache-for-pr
# Commit to gitgit add lib/active_model/serializer/caching.rbgit commit -m "better docs for ActiveModel::Serializer::Caching#fetch_fragment_cache"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-ActiveModel--Serializer--Caching-fetch_fragment_cache-for-pr
hub pull-request
# Celebrate!