Sha256: 8315665ee9a97e25200f4d7567f31fb25619c86abbd8d7cf5c842f49e30f43ce

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module PubsubNotifier
  class Base
    class << self
      def use(name, options = {})
        @_client = (clients[name.to_sym] || clients[:logger]).new(options)
      end

      def client
        @_client ||= clients[:logger].new
      end

      private

        def clients
          PubsubNotifier.config.clients
        end

        def method_missing(method_name, *args, &block)
          super unless public_instance_methods.include?(method_name.to_sym)
          new.public_send(method_name, *args, &block)
        end

        def respond_to_missing?(method_name, include_private = false)
          public_instance_methods.include?(method_name.to_sym) || super
        end
    end

    private

      def client
        self.class.client
      end

      def method_missing(method_name, *args, &block)
        super unless client.respond_to?(method_name.to_sym)
        client.public_send(method_name, *args, &block)
      end

      def respond_to_missing?(method_name, include_private = false)
        client.respond_to?(method_name.to_sym) || super
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pubsub_notifier-0.1.2 lib/pubsub_notifier/base.rb
pubsub_notifier-0.1.1 lib/pubsub_notifier/base.rb