Class: JSTP::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/jstp/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original, query, engine, client = nil) ⇒ Controller

Returns a new instance of Controller.



5
6
7
8
9
10
11
12
13
# File 'lib/jstp/controller.rb', line 5

def initialize original, query, engine, client = nil
  @original = original
  @engine = engine

  @query = query
  @client = client unless client.nil?

  Configuration.instance.logger.info original.to.short
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def body
  @body
end

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def client
  @client
end

#engineObject (readonly)

Returns the value of attribute engine.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def engine
  @engine
end

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def method
  @method
end

#originalObject (readonly)

Returns the value of attribute original.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def original
  @original
end

#protocolObject (readonly)

Returns the value of attribute protocol.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def protocol
  @protocol
end

#queryObject (readonly)

Returns the value of attribute query.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def query
  @query
end

#refererObject (readonly)

Returns the value of attribute referer.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def referer
  @referer
end

#resourceObject (readonly)

Returns the value of attribute resource.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def resource
  @resource
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def timestamp
  @timestamp
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/jstp/controller.rb', line 3

def token
  @token
end

Instance Method Details

#dispatch(*args) ⇒ Object

Since it delegates Reader::Dispatch, the method is

Parameters:

  • Method
  • Resource
  • Body
  • Headers


20
21
22
23
24
25
26
# File 'lib/jstp/controller.rb', line 20

def dispatch *args
  @dispatch = Dispatch.new @original
  @dispatch.referer = [Configuration.instance.hostname] + (self.class.to_s.split("::") - engine.class.to_s.split("::"))
  @dispatch.from.array args

  @dispatch
end