Class: WarningSigns::MessageFormatterList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/warning_signs/message_formatter_list.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_formatters: [], message_formatter: nil) ⇒ MessageFormatterList

Returns a new instance of MessageFormatterList.



7
8
9
10
11
12
# File 'lib/warning_signs/message_formatter_list.rb', line 7

def initialize(message_formatters: [], message_formatter: nil)
  @message_formatters = message_formatters.map do
    MessageFormatter::Base.for(**_1)
  end
  @message_formatters << MessageFormatter::Base.for(**message_formatter) if message_formatter
end

Instance Attribute Details

#message_formattersObject (readonly)

Returns the value of attribute message_formatters.



5
6
7
# File 'lib/warning_signs/message_formatter_list.rb', line 5

def message_formatters
  @message_formatters
end

Instance Method Details

#behavior_match(behavior) ⇒ Object



18
19
20
21
22
23
# File 'lib/warning_signs/message_formatter_list.rb', line 18

def behavior_match(behavior)
  message_formatters.find do
    _1.behaviors.only_except_match?(behavior) &&
      _1.environments.only_except_match?(Rails.env)
  end
end

#each(&block) ⇒ Object



14
15
16
# File 'lib/warning_signs/message_formatter_list.rb', line 14

def each(&block)
  message_formatters.each(&block)
end