Skip to content

Commit

Permalink
Refactor fragment cache methods
Browse files Browse the repository at this point in the history
Removed extra calls to constantize and DRY'd the code.
  • Loading branch information
Yohan Robert committed Mar 8, 2016
1 parent f8d2aab commit 580139f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 114 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Features:
- [#1340](https://github.com/rails-api/active_model_serializers/pull/1340) Add support for resource-level meta. (@beauby)

Fixes:
- [#1516](https://github.com/rails-api/active_model_serializers/pull/1501) No longer return a nil href when only
- [#1516](https://github.com/rails-api/active_model_serializers/pull/1516) No longer return a nil href when only
adding meta to a relationship link. (@groyoh)
- [#1458](https://github.com/rails-api/active_model_serializers/pull/1458) Preserve the serializer
type when fragment caching. (@bdmac)
Expand All @@ -31,6 +31,7 @@ Fixes:
- [#1488](https://github.com/rails-api/active_model_serializers/pull/1488) Require ActiveSupport's string inflections (@nate00)

Misc:
- [#1527](https://github.com/rails-api/active_model_serializers/pull/1527) Refactor fragment cache class. (@groyoh)
- [#1560](https://github.com/rails-api/active_model_serializers/pull/1560) Update rubocop and address its warnings. (@bf4 @groyoh)
- [#1545](https://github.com/rails-api/active_model_serializers/pull/1545) Document how to pass arbitrary options to the
serializer (@CodedBeardedSignedTaylor)
Expand Down
36 changes: 36 additions & 0 deletions lib/active_model/serializer/adapter/fragment_cache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module ActiveModel
class Serializer
module Adapter
class FragmentCache
attr_reader :serializer

def initialize(adapter, serializer, options)
@instance_options = options
@adapter = adapter
@serializer = serializer
end

# 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+
def fetch

end

protected

attr_reader :instance_options, :adapter

private





def to_valid_const_name(name)
name.gsub('::', '_')
end
end
end
end
end
113 changes: 0 additions & 113 deletions lib/active_model_serializers/adapter/fragment_cache.rb

This file was deleted.

0 comments on commit 580139f

Please sign in to comment.