Sha256: 37160ca25eae6fee1d4cd26ac9d5a1893fccdc7f2843fa9a369578c02b5762f5

Contents?: true

Size: 628 Bytes

Versions: 1

Compression:

Stored size: 628 Bytes

Contents

require 'hashmake'

module SPNet
class CommandInPort < InPort
  
  include Hashmake::HashMakeable

  ARG_SPECS = [
    Hashmake::ArgSpec.new(:key => :list_commands_handler, :reqd => true, :type => Proc),
    Hashmake::ArgSpec.new(:key => :exec_command_handler, :reqd => true, :type => Proc)
  ]

  def initialize hashed_args
    hash_make(CommandInPort::ARG_SPECS, hashed_args)
    hashed_args.merge!(:matching_port_class => CommandOutPort)
    super(hashed_args)
  end
  
  def list_commands
    @list_commands_handler.call
  end
  
  def exec_command command, data
    @exec_command_handler.call command, data
  end  
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spnet-0.1.3 lib/spnet/ports/command_in_port.rb