Class: Formatter::WorkItemsLimit
- Defined in:
- lib/bas/formatter/work_items_limit.rb
Overview
This class implements methods from the Formatter::Base module, tailored to format the Domain::WorkItemsLimit structure for a dispatcher.
Constant Summary collapse
- DEFAULT_DOMAIN_LIMIT =
6
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#format(work_items_list) ⇒ Object
Implements the logic for building a formatted payload with the given template for wip limits.
-
#initialize(config = {}) ⇒ WorkItemsLimit
constructor
Initializes the formatter with essential configuration parameters.
Constructor Details
#initialize(config = {}) ⇒ WorkItemsLimit
Initializes the formatter with essential configuration parameters.
limits : expect a map with the wip limits by domain. Example: { “ops”: 5 }
17 18 19 20 21 |
# File 'lib/bas/formatter/work_items_limit.rb', line 17 def initialize(config = {}) super(config) @limits = config[:limits] end |
Instance Method Details
#format(work_items_list) ⇒ Object
Implements the logic for building a formatted payload with the given template for wip limits.
Params:
-
List<Domain::WorkItemsLimit>
work_items_list: List of mapped work items limits.
raises Formatter::Exceptions::InvalidData
when invalid data is provided.
returns String
payload, formatted payload suitable for a Dispatcher.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bas/formatter/work_items_limit.rb', line 36 def format(work_items_list) raise Formatter::Exceptions::InvalidData unless work_items_list.all? do |work_item| work_item.is_a?(Domain::WorkItemsLimit) end exceeded_domains(work_items_list).reduce("") do |payload, work_items_limit| built_template = build_template(Domain::WorkItemsLimit::ATTRIBUTES, work_items_limit) payload + (built_template.gsub("\n", ""), work_items_limit) end end |