Top Level Namespace
Defined Under Namespace
Modules: Dataset, Nephos Classes: BinError, InvalidApplication, InvalidGit, InvalidRoute, InvalidRouteController, InvalidRouteMethod, InvalidRouteTo, InvalidRouteUrl, MainController, MissingKey, NoGitBinary, ParsingError, RoutingError
Instance Method Summary collapse
-
#add_route(verb, option_url = nil, what) ⇒ Object
The method create a valid route, set in Nephos::Router::ROUTES it will call the method from the controller, based on the parameters if the client request match with the verb and the url provided.
-
#alias_route ⇒ Object
An alias is an url which have the same proprieties than the previous route.
- #get(url = nil, what) ⇒ Object
- #post(url = nil, what) ⇒ Object
- #put(url = nil, what) ⇒ Object
-
#resource(name, &block) ⇒ Object
Create a resource named based on the parameter name Every call of #add_route #get #post #put in the bloc will have a modified url, working with the following schema: “/name/” + url.
- #route_prefix ⇒ Object
Instance Method Details
#add_route(verb, option_url = nil, what) ⇒ Object
The method create a valid route, set in Nephos::Router::ROUTES it will call the method from the controller, based on the parameters if the client request match with the verb and the url provided.
Checkout the documentation about the parameters and API for more informations
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/nephos-server/router/helpers.rb', line 20 def add_route(verb, option_url=nil, what) raise InvalidRoute, "what must be a hash" unless what.is_a? Hash what[:url] ||= option_url Array(what[:url]).each do |url| route = what.dup route[:url] = url route[:url] = File. File.join(route_prefix, route[:url]) Nephos::Router.check!(route) Nephos::Router.add_params!(route) Nephos::Router.add(route, verb) end end |
#alias_route ⇒ Object
An alias is an url which have the same proprieties than the previous route
66 67 68 |
# File 'lib/nephos-server/router/helpers.rb', line 66 def alias_route raise "Not implemented yet" end |
#get(url = nil, what) ⇒ Object
35 36 37 |
# File 'lib/nephos-server/router/helpers.rb', line 35 def get url=nil, what add_route "GET", url, what end |
#post(url = nil, what) ⇒ Object
41 42 43 |
# File 'lib/nephos-server/router/helpers.rb', line 41 def post url=nil, what add_route "POST", url, what end |
#put(url = nil, what) ⇒ Object
47 48 49 |
# File 'lib/nephos-server/router/helpers.rb', line 47 def put url=nil, what add_route "PUT", url, what end |
#resource(name, &block) ⇒ Object
Create a resource named based on the parameter name Every call of #add_route #get #post #put in the bloc will have a modified url, working with the following schema:
"/name/" + url
58 59 60 61 62 63 |
# File 'lib/nephos-server/router/helpers.rb', line 58 def resource(name, &block) @route_prefix ||= [] @route_prefix << name block.call @route_prefix.pop end |
#route_prefix ⇒ Object
1 2 3 4 |
# File 'lib/nephos-server/router/helpers.rb', line 1 def route_prefix @route_prefix ||= [] File.join(["/"] + @route_prefix) end |