Class: Xencap::RequestDispatcher
- Inherits:
-
Object
- Object
- Xencap::RequestDispatcher
- Defined in:
- lib/xencap/request_dispatcher.rb
Instance Method Summary collapse
- #dispatch(scope, *args) ⇒ Object
-
#initialize(session) ⇒ RequestDispatcher
constructor
A new instance of RequestDispatcher.
Constructor Details
#initialize(session) ⇒ RequestDispatcher
Returns a new instance of RequestDispatcher.
2 3 4 5 6 7 |
# File 'lib/xencap/request_dispatcher.rb', line 2 def initialize(session) @session = session @proxy_classes = Dir[File.("../session_proxy/*rb", __FILE__)] @proxies = {} end |
Instance Method Details
#dispatch(scope, *args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/xencap/request_dispatcher.rb', line 9 def dispatch(scope, *args) if @proxies.has_key?(scope) # nothing to do here elsif filename = @proxy_classes.detect {|file| File.basename(file, ".rb").downcase == scope.to_s} require filename @proxies[scope] = Xencap::SessionProxy.const_get(scope.capitalize).new(@session) else @proxies[scope] = Xencap::SessionProxy.new(@session, scope) end @proxies[scope] end |