Sha256: 8a8a4238151e593417ebae93cdf1ee55db3ab9a9faefda1d42212bf972beaec1
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
module Nephos # This class must be inherited by the other Controllers. # It contains a constructor (you should not rewrite it) # It contains some helpers too, like an access to the environment, # and the parameters. class Controller attr_reader :env, :infos, :callpath, :params, :cookies # @param env [Hash] env extracted from the http request # @param parsed [Hash] pre-parsed env with parameters, ... def initialize env={}, parsed={path: [], params: {}}, 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. :params must be associated with a Hash" unless parsed[:params].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[:params] @params.merge! Hash[callpath[:params].zip @infos[:path]] @params.select!{|k,v| not k.to_s.empty?} @params = Params.new(@params) @cookies = Params.new() end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nephos-server-0.5.2 | lib/nephos-server/controller.rb |