mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Consider evaluating association in serializer context
For discussion: Consider evaluating association in serializer context That way, associations are really just anything that can be conditionally included. They no longer have to actually be methods on the object or serializer. e.g. ```diff has_many :comments do - last(1) + Comment.active.for_serialization(object).last(1) end ```
This commit is contained in:
2
test/fixtures/poro.rb
vendored
2
test/fixtures/poro.rb
vendored
@@ -33,6 +33,7 @@ end
|
||||
class ProfileSerializer < ActiveModel::Serializer
|
||||
attributes :name, :description
|
||||
|
||||
# TODO: is this used anywhere?
|
||||
def arguments_passed_in?
|
||||
instance_options[:my_options] == :accessible
|
||||
end
|
||||
@@ -75,6 +76,7 @@ PostSerializer = Class.new(ActiveModel::Serializer) do
|
||||
Blog.new(id: 999, name: 'Custom blog')
|
||||
end
|
||||
|
||||
# TODO: is this used anywhere?
|
||||
def custom_options
|
||||
instance_options
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user