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
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/grape/formatters/active_model_serializers.rb', line 16 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
11 12 13 14 |
# File 'lib/grape/formatters/active_model_serializers.rb', line 11 def self.call(resource, env) = (env) ::ActiveModelSerializers::SerializableResource.new(resource, ).to_json end |