Class: Nephos::Controller

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

Direct Known Subclasses

MainController

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Controller.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nephos-server/controller.rb', line 8

def initialize env={}, parsed={path: [], args: {}}, callpath={params: []}
  raise ArgumentError, "env must be a Hash" unless env.is_a? Hash
  raise ArgumentError, "parsed must be a Hash" unless parsed.is_a? Hash
  raise ArgumentError, "callpath must be a Hash" unless callpath.is_a? Hash
  raise ArgumentError, "Invalid Parsed. :path must be associated with an Array" unless parsed[:path].is_a? Array
  raise ArgumentError, "Invalid Parsed. :args must be associated with a Hash" unless parsed[:args].is_a? Hash
  raise ArgumentError, "Invalid Callpath. :params must be associated with an Array" unless callpath[:params].is_a? Array
  @env= env
  @infos= parsed
  @callpath= callpath
  @params= parsed[:args]
  @params.merge! Hash[callpath[:params].zip @infos[:path]]
  @params.select!{|k,v| not k.to_s.empty?}
  @params = Params.new(@params)
end

Instance Attribute Details

#callpathObject (readonly)

Returns the value of attribute callpath.



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

def callpath
  @callpath
end

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
end

#infosObject (readonly)

Returns the value of attribute infos.



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

def infos
  @infos
end

#paramsObject (readonly)

Returns the value of attribute params.



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

def params
  @params
end