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)


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

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|
      # `block` instead of `&block`

      instance_exec(meth, msg, block, &def_block)
    end
  end
end