require 'twterm/event_dispatcher'

module Twterm
  module Subscriber
    def subscribe(event, callback = nil, &block)
      cb = if callback.is_a?(Proc)
             callback
           elsif callback.is_a?(Symbol)
             if self.respond_to?(callback)
               self.method(callback)
             else
               callback.to_proc
             end
           elsif callback.nil?
             block
           end

      EventDispatcher.instance.register_subscription(object_id, event, cb)
    end

    def unsubscribe(event = nil)
      EventDispatcher.instance.unregister_subscription(object_id, event)
    end

    def self.included(base)
      base.instance_eval do
        private :subscribe, :unsubscribe
      end
    end
  end
end

require 'twterm/event_dispatcher'

module Twterm
  module Subscriber
    def subscribe(event, callback = nil, &block)
      cb = if callback.is_a?(Proc)
             callback
           elsif callback.is_a?(Symbol)
             if self.respond_to?(callback, true)
               self.method(callback)
             else
               callback.to_proc
             end
           elsif callback.nil?
             block
           end

      EventDispatcher.instance.register_subscription(object_id, event, cb)
    end

    def unsubscribe(event = nil)
      EventDispatcher.instance.unregister_subscription(object_id, event)
    end

    def self.included(base)
      base.instance_eval do
        private :subscribe, :unsubscribe
      end
    end
  end
end

Enable to subscribe events with private methods
Enable to subscribe events with private methods

Specify true in the second argument of `respond_to?` method in order to
check if the receiver has the method including private ones
