Sha256: 06c32f684ae39df08bee27346720c7370b9caddf494c8f9c0a2a551787eff00e

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

require "active_model"
require_relative "model" unless defined?(ActiveModel::Model)

module MultiNotifier
  module Middlewares
    class Middleware
      include ActiveModel::Model

      def notify
        raise "Implement #{self.class.name}#notify"
      end

      def notify!
        raise error_msg(errors.messages) unless valid?

        notify
      end

      private

      def error_msg(messages)
        messages.map do |key, value|
          value.map { |v| "#{key} #{v}" }
        end.flatten.join("\n")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_notifier-0.4.0 lib/multi_notifier/middleware.rb