Sha256: 4cd82ef9d686be0dddd9df18909143d3300d560740a136be55f2743570428204

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

module PubsubNotifier
  module ActsAsNotifier
    def self.included(klass)
      klass.extend ClassMethods
    end

    module ClassMethods
      def acts_as_notifier
        class_eval do
          class << self
            private
              # Override ActionMailer::Base#method_missing
              # https://github.com/rails/rails/blob/master/actionmailer/lib/action_mailer/base.rb#L576
              def method_missing(method_name, *args)
                if action_methods.include?(method_name.to_s)
                  ::ActionMailer::MessageDelivery.new(self, method_name, *args).tap(&:deliver)
                else
                  super
                end
              end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pubsub_notifier-0.1.0 lib/pubsub_notifier/acts_as_notifier.rb