mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Makes passed in options accessible inside serializers
In some cases, we want to pass arguments from the controller and we want to serializer a resource according to that. This allows serializers to use the `options` method to retrieve whatever was passed in via arguments.
This commit is contained in:
4
test/fixtures/poro.rb
vendored
4
test/fixtures/poro.rb
vendored
@@ -45,6 +45,10 @@ class ProfileSerializer < ActiveModel::Serializer
|
||||
attributes :name, :description
|
||||
|
||||
urls :posts, :comments
|
||||
|
||||
def arguments_passed_in?
|
||||
options[:my_options] == :accessible
|
||||
end
|
||||
end
|
||||
|
||||
class ProfilePreviewSerializer < ActiveModel::Serializer
|
||||
|
||||
Reference in New Issue
Block a user