Sha256: f2fc96d93615673d6b5026097941ee80b4258290487c747b938dc7871345e663

Contents?: true

Size: 1008 Bytes

Versions: 1

Compression:

Stored size: 1008 Bytes

Contents

module Eco
  module API
    module Common
      module Session
        class Logger
          module Channels
            CHANNELS = %i[general].freeze

            class << self
              def included(base)
                super
                base.extend ClassMethods
              end
            end

            module ClassMethods
              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

              private

              def channels
                self::CHANNELS
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/common/session/logger/channels.rb