Class: Nephos::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/nephos-server/routing/controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env = {}, parsed = {path: [], args: {}}, callpath = {params: []}) ⇒ Controller

Returns a new instance of Controller.

Parameters:

  • env (Hash) (defaults to: {})

    env extracted from the http request

  • parsed (Hash) (defaults to: {path: [], args: {}})

    pre-parsed env with parameters, …



8
9
10
11
12
13
14
15
# File 'lib/nephos-server/routing/controller.rb', line 8

def initialize env={}, parsed={path: [], args: {}}, callpath={params: []}
  @env= env
  @infos= parsed
  @callpath= callpath
  @params= parsed[:args]
  @params.merge! Hash[callpath[:params].zip @infos[:path]]
  @params.select!{|k,v|k}
end

Instance Attribute Details

#callpathObject (readonly)

Returns the value of attribute callpath.



4
5
6
# File 'lib/nephos-server/routing/controller.rb', line 4

def callpath
  @callpath
end

#envObject (readonly)

Returns the value of attribute env.



4
5
6
# File 'lib/nephos-server/routing/controller.rb', line 4

def env
  @env
end

#infosObject (readonly)

Returns the value of attribute infos.



4
5
6
# File 'lib/nephos-server/routing/controller.rb', line 4

def infos
  @infos
end

Instance Method Details

#argumentsObject Also known as: params



17
18
19
# File 'lib/nephos-server/routing/controller.rb', line 17

def arguments
  @params
end