Sha256: e215edd0545e556de641bf911c1806496a16c5f4d69574cb475a5da0f778b5cd

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

module Surrounded
  module Context
    module Forwarding
      def forward_trigger(receiver, message, alternate=message)
        raise(ArgumentError, %{you may not forward '%{m}`} % {m: message}) if ['__id__','__send__'].include?(message.to_s)
        trigger alternate do
          self.send(receiver).public_send(message)
        end
      end
      
      def forward_triggers(receiver, *messages)
        messages.each do |message|
          forward_trigger(receiver, message)
        end
      end
      
      def forwarding(hash)
        hash.each { |messages, receiver|
          forward_triggers(receiver, *messages)
        }
      end
      
      alias forward forward_trigger
      alias forwards forward_triggers
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
surrounded-0.9.3 lib/surrounded/context/forwarding.rb
surrounded-0.9.2 lib/surrounded/context/forwarding.rb
surrounded-0.9.1 lib/surrounded/context/forwarding.rb