Class: Formatter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/bas/formatter/base.rb

Overview

The Formatter::Base module serves as the foundation for implementing specific data presentation logic within the Formatter module. Defines essential methods, that provide a blueprint for creating custom formatters tailored to different use cases.

Direct Known Subclasses

Birthday, Pto, SupportEmails, WorkItemsLimit

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Base

Initializes the fetcher with essential configuration parameters.



17
18
19
20
# File 'lib/bas/formatter/base.rb', line 17

def initialize(config = {})
  @config = config
  @template = config[:template]
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



13
14
15
# File 'lib/bas/formatter/base.rb', line 13

def template
  @template
end

Instance Method Details

#format(_domain_data) ⇒ Object

This method is designed to provide a specified format for data from any implementation of the Mapper::Base interface. Must be overridden by subclasses, with specific logic based on the use case.


Params:

  • List<Domain::> domain_data: List of specific domain objects depending on the use case.


raises Domain::Exceptions::FunctionNotImplemented when missing implementation.

returns String Formatted payload suitable for a Dispatcher::Base implementation.



35
36
37
# File 'lib/bas/formatter/base.rb', line 35

def format(_domain_data)
  raise Domain::Exceptions::FunctionNotImplemented
end