Sha256: c81d74ac6156c4a034016c7e493673bb1e9c4f08e58f3e37e8bc4a30da522c52

Contents?: true

Size: 1.06 KB

Versions: 1

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

1 entries across 1 versions & 1 rubygems

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