Skip to content

Commit

Permalink
rename each_serializer to serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
ggordon committed Oct 27, 2014
1 parent f1c3752 commit d3d72b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def each_association(&block)
serializer_class = ActiveModel::Serializer.serializer_for(association, options)
serializer = serializer_class.new(
association,
each_serializer_from_options(options)
serializer_from_options(options)
)

if block_given?
Expand All @@ -144,10 +144,10 @@ def each_association(&block)
end
end

def each_serializer_from_options(options)
def serializer_from_options(options)
opts = {}
each_serializer = options.fetch(:options, {}).fetch(:serializer, nil)
opts[:each_serializer] = each_serializer if each_serializer
serializer = options.fetch(:options, {}).fetch(:serializer, nil)
opts[:serializer] = serializer if serializer
opts
end

Expand Down
5 changes: 4 additions & 1 deletion lib/active_model/serializer/array_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ class ArraySerializer
def initialize(objects, options = {})
@objects = objects.map do |object|
serializer_class =
options.fetch(:each_serializer, ActiveModel::Serializer.serializer_for(object))
options.fetch(
:serializer,
ActiveModel::Serializer.serializer_for(object)
)
serializer_class.new(object)
end
end
Expand Down

0 comments on commit d3d72b0

Please sign in to comment.