@@ -240,8 +240,8 @@ class AwardSerializer
240240 include FastJsonapi ::ObjectSerializer
241241 attributes :id , :title
242242 attribute :year , if : Proc . new { |record , params |
243- params [ :include_award_year ] . present? ?
244- params [ :include_award_year ] :
243+ params [ :include_award_year ] . present? ?
244+ params [ :include_award_year ] :
245245 false
246246 }
247247 belongs_to :actor
@@ -313,7 +313,7 @@ class MovieOptionalParamsDataSerializer
313313 include FastJsonapi ::ObjectSerializer
314314 set_type :movie
315315 attributes :name
316- attribute :director , if : Proc . new { |record , params | params && params [ :admin ] == true }
316+ attribute :director , if : Proc . new { |record , params | params [ :admin ] == true }
317317 end
318318
319319 class MovieOptionalRelationshipSerializer
@@ -327,7 +327,19 @@ class MovieOptionalRelationshipWithParamsSerializer
327327 include FastJsonapi ::ObjectSerializer
328328 set_type :movie
329329 attributes :name
330- belongs_to :owner , record_type : :user , if : Proc . new { |record , params | params && params [ :admin ] == true }
330+ belongs_to :owner , record_type : :user , if : Proc . new { |record , params | params [ :admin ] == true }
331+ end
332+
333+ class MovieOptionalAttributeContentsWithParamsSerializer
334+ include FastJsonapi ::ObjectSerializer
335+ set_type :movie
336+ attributes :name
337+ attribute :director do |record , params |
338+ data = { }
339+ data [ :first_name ] = 'steven'
340+ data [ :last_name ] = 'spielberg' if params [ :admin ]
341+ data
342+ end
331343 end
332344 end
333345
0 commit comments