Module: Eco::API::Common::Session::Logger::Channels::ClassMethods

Defined in:
lib/eco/api/common/session/logger/channels.rb

Instance Method Summary collapse

Instance Method Details

#channels!(&def_block) ⇒ Object

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/eco/api/common/session/logger/channels.rb', line 17

def channels!(&def_block)
  str = "Block with channel implementation expected. None given."
  raise ArgumentError, str unless block_given?

  channels.each do |channel|
    meth = channel.to_s.downcase.to_sym

    define_method(meth) do |msg = nil, &block|
      def_block.call(meth, msg, &block)
    end
  end
end