Class: Dionysus::Producer::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/serializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record_or_records, dependencies: []) ⇒ Serializer

Returns a new instance of Serializer.



11
12
13
14
15
# File 'lib/dionysus/producer/serializer.rb', line 11

def initialize(record_or_records, dependencies: [])
  @records = Array.wrap(record_or_records).compact

  @dependencies = dependencies
end

Class Method Details

.serialize(record_or_records, dependencies: []) ⇒ Object



4
5
6
# File 'lib/dionysus/producer/serializer.rb', line 4

def self.serialize(record_or_records, dependencies: [])
  new(record_or_records, dependencies: dependencies).serialize
end

Instance Method Details

#serializeObject



17
18
19
20
21
22
# File 'lib/dionysus/producer/serializer.rb', line 17

def serialize
  records.map do |record|
    serializer = resolve_serializer_for_record(record)
    serializer.as_json
  end
end