Class: Formatter::Birthday
Overview
This class implements methods from the Formatter::Base module, tailored to format the Domain::Birthday structure for a dispatcher.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#format(birthdays_list) ⇒ Object
Implements the logic for building a formatted payload with the given template for birthdays.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Formatter::Base
Instance Method Details
#format(birthdays_list) ⇒ Object
Implements the logic for building a formatted payload with the given template for birthdays.
Params:
-
List<Domain::Birthday>
birthdays_list: list of mapped birthdays.
raises Formatter::Exceptions::InvalidData
when invalid data is provided.
returns String
payload: formatted payload suitable for a Dispatcher.
24 25 26 27 28 29 30 31 32 |
# File 'lib/bas/formatter/birthday.rb', line 24 def format(birthdays_list) raise Formatter::Exceptions::InvalidData unless birthdays_list.all? do |brithday| brithday.is_a?(Domain::Birthday) end birthdays_list.reduce("") do |payload, birthday| payload + build_template(Domain::Birthday::ATTRIBUTES, birthday) end end |