Module: Grape::Formatters::ActiveModelSerializers
- Defined in:
- lib/grape/formatters/active_model_serializers.rb
Class Method Summary collapse
Class Method Details
.build_serializer_options(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/grape/formatters/active_model_serializers.rb', line 18 def self.(env) = env[:active_model_serializer_options] || {} # Add serialization context .fetch(:serialization_context) do request = env['grape.request'] [:serialization_context] = ::ActiveModelSerializers::SerializationContext.new( request_url: request.url[/\A[^?]+/], query_parameters: request.params ) end end |
.call(resource, env) ⇒ Object
13 14 15 16 |
# File 'lib/grape/formatters/active_model_serializers.rb', line 13 def self.call(resource, env) = (env) ::ActiveModelSerializers::SerializableResource.new(resource, ).to_json end |