Class: RecordNotFoundSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/serializers/record_not_found_serializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ RecordNotFoundSerializer

Returns a new instance of RecordNotFoundSerializer.



4
5
6
7
# File 'lib/serializers/record_not_found_serializer.rb', line 4

def initialize(error)
  @error = error
  @resource = error.model.underscore
end

Instance Method Details

#serializeObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/serializers/record_not_found_serializer.rb', line 9

def serialize
  {
    success: false,
    errors: [
      {
        resource: resource,
        field: nil
      }.merge(details)
    ]
  }
end