Sha256: bea63cd8d48929be97a36ff145685cd6e6f98e6664a060a578d1d9353b87b743

Contents?: true

Size: 711 Bytes

Versions: 2

Compression:

Stored size: 711 Bytes

Contents

module LucidChannel
  module Mixin
    def self.included(base)
      base.instance_exec do
        def process_message(message)
          if @message_processor
            @message_processor.call(message)
          else
            puts "#{self} received: #{message}, but no processor defined!"
          end
        end

        def on_message(&block)
          @message_processor = block
        end

        def send_message(message)
          Isomorfeus::Transport.send_notification(self, message)
        end

        def subscribe
          Isomorfeus::Transport.subscribe(self)
        end

        def unsubscribe
          Isomorfeus::Transport.unsubscribe(self)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
isomorfeus-transport-1.0.0.delta8 lib/lucid_channel/mixin.rb
isomorfeus-transport-1.0.0.delta7 lib/lucid_channel/mixin.rb