Class: CommandTower::Messaging::Contract::Mappers::CommunicationMapper
- Inherits:
-
Object
- Object
- CommandTower::Messaging::Contract::Mappers::CommunicationMapper
- Defined in:
- app/services/command_tower/messaging/contract/mappers/communication_mapper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(communication) ⇒ CommunicationMapper
constructor
A new instance of CommunicationMapper.
- #to_result ⇒ Object
Constructor Details
#initialize(communication) ⇒ CommunicationMapper
Returns a new instance of CommunicationMapper.
12 13 14 |
# File 'app/services/command_tower/messaging/contract/mappers/communication_mapper.rb', line 12 def initialize(communication) @communication = communication end |
Class Method Details
.to_result(communication) ⇒ Object
8 9 10 |
# File 'app/services/command_tower/messaging/contract/mappers/communication_mapper.rb', line 8 def self.to_result(communication) new(communication).to_result end |
Instance Method Details
#to_result ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/command_tower/messaging/contract/mappers/communication_mapper.rb', line 16 def to_result result = Results::CommunicationResult.new( id: communication.id, recipient_id: communication.user_id, notification_type_key: communication.notification_type_key, title: communication.title, body: communication.body, metadata: (communication.), created_at: communication.created_at, destination_plan: DestinationPlanMapper.to_result(communication.destination_plan), inbox_item: InboxItemMapper.to_result(communication.inbox_item), channel_deliveries: communication.channel_deliveries.map do |delivery| ChannelDeliveryMapper.to_result(delivery) end.freeze, ).freeze assert_no_active_record!(result) result end |