Module: PlainSerializer::Modifiable
- Included in:
- Base
- Defined in:
- lib/plain_serializer/modifiable.rb
Overview
Module which adds support of modifying output
Instance Method Summary collapse
Instance Method Details
#serialize(entity, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/plain_serializer/modifiable.rb', line 6 def serialize(entity, &block) result = super(entity) return if result.nil? block&.call(result, entity) result end |
#serialize_collection(entities, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/plain_serializer/modifiable.rb', line 16 def serialize_collection(entities, &block) return if entities.nil? entities.each_with_object([]) do |entity, result| result << serialize(entity, &block) end end |