Class: ActiveModel::Serializer::ErrorsSerializer

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/active_model/serializer/errors_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources, options = {}) ⇒ ErrorsSerializer

Returns a new instance of ErrorsSerializer.



12
13
14
15
16
17
18
19
# File 'lib/active_model/serializer/errors_serializer.rb', line 12

def initialize(resources, options = {})
  @root = options[:root]
  @object = resources
  @serializers = resources.map do |resource|
    serializer_class = options.fetch(:serializer) { ActiveModel::Serializer::ErrorSerializer }
    serializer_class.new(resource, options.except(:serializer))
  end
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



10
11
12
# File 'lib/active_model/serializer/errors_serializer.rb', line 10

def object
  @object
end

#rootObject (readonly)

Returns the value of attribute root.



10
11
12
# File 'lib/active_model/serializer/errors_serializer.rb', line 10

def root
  @root
end

Instance Method Details

#json_keyObject



25
26
27
# File 'lib/active_model/serializer/errors_serializer.rb', line 25

def json_key
  nil
end

#success?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/active_model/serializer/errors_serializer.rb', line 21

def success?
  false
end