Class: ActiveModel::Serializer::ErrorsSerializer
- Inherits:
-
Object
- Object
- ActiveModel::Serializer::ErrorsSerializer
- Includes:
- Enumerable
- Defined in:
- lib/active_model/serializer/errors_serializer.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(resources, options = {}) ⇒ ErrorsSerializer
constructor
A new instance of ErrorsSerializer.
- #json_key ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(resources, options = {}) ⇒ ErrorsSerializer
Returns a new instance of ErrorsSerializer.
10 11 12 13 14 15 16 17 |
# File 'lib/active_model/serializer/errors_serializer.rb', line 10 def initialize(resources, = {}) @root = [:root] @object = resources @serializers = resources.map do |resource| serializer_class = .fetch(:serializer) { ActiveModel::Serializer::ErrorSerializer } serializer_class.new(resource, .except(:serializer)) end end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
8 9 10 |
# File 'lib/active_model/serializer/errors_serializer.rb', line 8 def object @object end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
8 9 10 |
# File 'lib/active_model/serializer/errors_serializer.rb', line 8 def root @root end |
Instance Method Details
#json_key ⇒ Object
23 24 25 |
# File 'lib/active_model/serializer/errors_serializer.rb', line 23 def json_key nil end |
#success? ⇒ Boolean
19 20 21 |
# File 'lib/active_model/serializer/errors_serializer.rb', line 19 def success? false end |