Module: SimpleDispatcher::SimpleDispatcherClassMethods

Defined in:
lib/simpledispatcher.rb

Instance Method Summary collapse

Instance Method Details

#AllowedCommandsObject

override inherit by replacing



66
67
68
# File 'lib/simpledispatcher.rb', line 66

def AllowedCommands
    @AllowedCommands ||  (superclass.AllowedCommands() if self.superclass.respond_to? :AllowedCommands) || []
end

#Dispatch(*args) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/simpledispatcher.rb', line 70

def Dispatch *args
    if self.AllowedCommands.include? args.first
        # without  instance id (use lowcase classname)
        inst = self.new self.name.gsub('::',"-").downcase
    else 
        # with instance id
        inst = self.new args.shift
    end
    inst.dispatch *args
    inst
end

#DispatchOpts(opts = {}) ⇒ Object

opts :id, :cmd



83
84
85
86
87
88
89
# File 'lib/simpledispatcher.rb', line 83

def DispatchOpts opts = {}
    id = opts[:id]
    id = self.name.gsub('::',"-").downcase unless id and id.length>0
    inst = self.new id
    inst.dispatchOpts opts
    inst
end