waves 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/Rakefile +64 -6
- data/app/configurations/development.rb.erb +2 -1
- data/app/configurations/mapping.rb.erb +1 -0
- data/app/configurations/production.rb.erb +1 -0
- data/app/lib/application.rb.erb +2 -2
- data/bin/waves +36 -1
- data/doc/HISTORY +44 -0
- data/doc/LICENSE +22 -0
- data/doc/rdoc/classes/Erubis/Context.html +218 -0
- data/doc/rdoc/classes/Kernel.html +145 -0
- data/doc/rdoc/classes/Symbol.html +154 -0
- data/doc/rdoc/classes/Tempfile.html +161 -0
- data/doc/rdoc/classes/Waves.html +455 -0
- data/doc/rdoc/classes/Waves/Application.html +371 -0
- data/doc/rdoc/classes/Waves/Blackboard.html +296 -0
- data/doc/rdoc/classes/Waves/Configurations.html +283 -0
- data/doc/rdoc/classes/Waves/Configurations/Base.html +209 -0
- data/doc/rdoc/classes/Waves/Configurations/Default.html +237 -0
- data/doc/rdoc/classes/Waves/Console.html +187 -0
- data/doc/rdoc/classes/Waves/Controllers.html +203 -0
- data/doc/rdoc/classes/Waves/Controllers/Base.html +151 -0
- data/doc/rdoc/classes/Waves/Controllers/Mixin.html +312 -0
- data/doc/rdoc/classes/Waves/Dispatchers.html +118 -0
- data/doc/rdoc/classes/Waves/Dispatchers/Base.html +198 -0
- data/doc/rdoc/classes/Waves/Dispatchers/Default.html +224 -0
- data/doc/rdoc/classes/Waves/Dispatchers/NotFoundError.html +122 -0
- data/doc/rdoc/classes/Waves/Dispatchers/Redirect.html +173 -0
- data/doc/rdoc/classes/Waves/Foundations.html +131 -0
- data/doc/rdoc/classes/Waves/Foundations/Default.html +179 -0
- data/doc/rdoc/classes/Waves/Foundations/Simple.html +167 -0
- data/doc/rdoc/classes/Waves/Helpers.html +176 -0
- data/doc/rdoc/classes/Waves/Helpers/AssetHelper.html +212 -0
- data/doc/rdoc/classes/Waves/Helpers/Common.html +213 -0
- data/doc/rdoc/classes/Waves/Helpers/Default.html +135 -0
- data/doc/rdoc/classes/Waves/Helpers/Form.html +201 -0
- data/doc/rdoc/classes/Waves/Helpers/Formatting.html +232 -0
- data/doc/rdoc/classes/Waves/Helpers/Model.html +194 -0
- data/doc/rdoc/classes/Waves/Helpers/NumberHelper.html +165 -0
- data/doc/rdoc/classes/Waves/Helpers/TagHelper.html +226 -0
- data/doc/rdoc/classes/Waves/Helpers/UrlHelper.html +242 -0
- data/doc/rdoc/classes/Waves/Helpers/View.html +163 -0
- data/doc/rdoc/classes/Waves/Inflect/InflectorMethods.html +475 -0
- data/doc/rdoc/classes/Waves/Layers.html +175 -0
- data/doc/rdoc/classes/Waves/Layers/DefaultErrors.html +161 -0
- data/doc/rdoc/classes/Waves/Layers/Inflect.html +119 -0
- data/doc/rdoc/classes/Waves/Layers/Inflect/English.html +168 -0
- data/doc/rdoc/classes/Waves/Layers/Inflect/English/Rules.html +112 -0
- data/doc/rdoc/classes/Waves/Layers/Inflect/English/StringMethods.html +194 -0
- data/doc/rdoc/classes/Waves/Layers/MVC.html +204 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord.html +239 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord/ControllerMethods.html +246 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord/Symbol.html +132 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/DataMapper.html +166 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/Filebase.html +157 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/Sequel.html +232 -0
- data/doc/rdoc/classes/Waves/Layers/ORM/Sequel/ControllerMethods.html +246 -0
- data/doc/rdoc/classes/Waves/Layers/Simple.html +169 -0
- data/doc/rdoc/classes/Waves/Layers/SimpleErrors.html +159 -0
- data/doc/rdoc/classes/Waves/Logger.html +288 -0
- data/doc/rdoc/classes/Waves/Mapping.html +760 -0
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls.html +129 -0
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls/GetRules.html +174 -0
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls/RestRules.html +180 -0
- data/doc/rdoc/classes/Waves/MimeTypes.html +200 -0
- data/doc/rdoc/classes/Waves/Renderers/Erubis.html +162 -0
- data/doc/rdoc/classes/Waves/Renderers/Haml.html +160 -0
- data/doc/rdoc/classes/Waves/Renderers/Markaby.html +167 -0
- data/doc/rdoc/classes/Waves/Renderers/Mixin.html +191 -0
- data/doc/rdoc/classes/Waves/Renderers/Scope.html +181 -0
- data/doc/rdoc/classes/Waves/Request.html +441 -0
- data/doc/rdoc/classes/Waves/Request/ParseError.html +111 -0
- data/doc/rdoc/classes/Waves/Response.html +283 -0
- data/doc/rdoc/classes/Waves/ResponseMixin.html +460 -0
- data/doc/rdoc/classes/Waves/ResponseProxy.html +269 -0
- data/doc/rdoc/classes/Waves/Server.html +488 -0
- data/doc/rdoc/classes/Waves/Session.html +330 -0
- data/doc/rdoc/classes/Waves/Utilities/Hash.html +185 -0
- data/doc/rdoc/classes/Waves/Utilities/Integer.html +424 -0
- data/doc/rdoc/classes/Waves/Utilities/Module.html +174 -0
- data/doc/rdoc/classes/Waves/Utilities/Object.html +155 -0
- data/doc/rdoc/classes/Waves/Utilities/Proc.html +145 -0
- data/doc/rdoc/classes/Waves/Utilities/String.html +290 -0
- data/doc/rdoc/classes/Waves/Views.html +278 -0
- data/doc/rdoc/classes/Waves/Views/Base.html +118 -0
- data/doc/rdoc/classes/Waves/Views/Mixin.html +279 -0
- data/doc/rdoc/classes/Waves/Views/NoTemplateError.html +111 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/README_rdoc.html +415 -0
- data/doc/rdoc/files/bin/waves.html +135 -0
- data/doc/rdoc/files/doc/HISTORY.html +265 -0
- data/doc/rdoc/files/lib/commands/waves-console_rb.html +110 -0
- data/doc/rdoc/files/lib/commands/waves-server_rb.html +108 -0
- data/doc/rdoc/files/lib/controllers/base_rb.html +101 -0
- data/doc/rdoc/files/lib/controllers/mixin_rb.html +101 -0
- data/doc/rdoc/files/lib/dispatchers/base_rb.html +101 -0
- data/doc/rdoc/files/lib/dispatchers/default_rb.html +101 -0
- data/doc/rdoc/files/lib/foundations/default_rb.html +101 -0
- data/doc/rdoc/files/lib/foundations/simple_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/asset_helper_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/common_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/default_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/form_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/formatting_rb.html +108 -0
- data/doc/rdoc/files/lib/helpers/model_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/number_helper_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/tag_helper_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/url_helper_rb.html +101 -0
- data/doc/rdoc/files/lib/helpers/view_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/default_errors_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/inflect/english/rules_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/inflect/english/string_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/inflect/english_rb.html +109 -0
- data/doc/rdoc/files/lib/layers/mvc_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/active_record/tasks/generate_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/active_record/tasks/schema_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/active_record_rb.html +108 -0
- data/doc/rdoc/files/lib/layers/orm/data_mapper_rb.html +108 -0
- data/doc/rdoc/files/lib/layers/orm/filebase_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/migration_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/sequel/tasks/generate_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/sequel/tasks/schema_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/orm/sequel_rb.html +108 -0
- data/doc/rdoc/files/lib/layers/simple_errors_rb.html +101 -0
- data/doc/rdoc/files/lib/layers/simple_rb.html +101 -0
- data/doc/rdoc/files/lib/mapping/mapping_rb.html +101 -0
- data/doc/rdoc/files/lib/mapping/pretty_urls_rb.html +101 -0
- data/doc/rdoc/files/lib/renderers/erubis_rb.html +108 -0
- data/doc/rdoc/files/lib/renderers/haml_rb.html +108 -0
- data/doc/rdoc/files/lib/renderers/markaby_rb.html +108 -0
- data/doc/rdoc/files/lib/renderers/mixin_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/application_rb.html +107 -0
- data/doc/rdoc/files/lib/runtime/blackboard_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/configuration_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/console_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/debugger_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/logger_rb.html +108 -0
- data/doc/rdoc/files/lib/runtime/mime_types_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/request_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/response_mixin_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/response_proxy_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/response_rb.html +101 -0
- data/doc/rdoc/files/lib/runtime/server_rb.html +108 -0
- data/doc/rdoc/files/lib/runtime/session_rb.html +101 -0
- data/doc/rdoc/files/lib/tasks/cluster_rb.html +101 -0
- data/doc/rdoc/files/lib/tasks/gem_rb.html +108 -0
- data/doc/rdoc/files/lib/tasks/generate_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/hash_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/inflect_rb.html +111 -0
- data/doc/rdoc/files/lib/utilities/integer_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/module_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/object_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/proc_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/string_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/symbol_rb.html +101 -0
- data/doc/rdoc/files/lib/utilities/tempfile_rb.html +115 -0
- data/doc/rdoc/files/lib/views/base_rb.html +101 -0
- data/doc/rdoc/files/lib/views/mixin_rb.html +101 -0
- data/doc/rdoc/files/lib/waves_rb.html +195 -0
- data/doc/rdoc/fr_class_index.html +104 -0
- data/doc/rdoc/fr_file_index.html +97 -0
- data/doc/rdoc/fr_method_index.html +233 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/foundations/default.rb +1 -0
- data/lib/layers/default_errors.rb +10 -13
- data/lib/layers/inflect/english.rb +24 -0
- data/lib/layers/inflect/english/rules.rb +88 -0
- data/lib/layers/inflect/english/string.rb +24 -0
- data/lib/layers/mvc.rb +31 -35
- data/lib/layers/orm/active_record.rb +83 -32
- data/lib/layers/orm/active_record/tasks/generate.rb +28 -0
- data/lib/layers/orm/active_record/tasks/schema.rb +7 -15
- data/lib/layers/orm/data_mapper.rb +12 -16
- data/lib/layers/orm/migration.rb +20 -11
- data/lib/layers/orm/sequel.rb +53 -49
- data/lib/layers/orm/sequel/tasks/generate.rb +28 -0
- data/lib/layers/orm/sequel/tasks/schema.rb +6 -14
- data/lib/layers/simple.rb +6 -13
- data/lib/layers/simple_errors.rb +5 -8
- data/lib/renderers/haml.rb +45 -0
- data/lib/runtime/application.rb +0 -2
- data/lib/tasks/cluster.rb +1 -1
- data/lib/utilities/inflect.rb +86 -168
- data/lib/utilities/integer.rb +23 -16
- data/lib/utilities/module.rb +19 -15
- data/lib/utilities/object.rb +22 -14
- data/lib/utilities/proc.rb +13 -7
- data/lib/utilities/string.rb +0 -12
- data/lib/utilities/symbol.rb +4 -1
- data/lib/utilities/tempfile.rb +9 -0
- data/lib/waves.rb +3 -1
- data/samples/blog/Rakefile +14 -0
- data/samples/blog/bin/waves-console +3 -0
- data/samples/blog/bin/waves-server +3 -0
- data/samples/blog/blog.db +0 -0
- data/samples/blog/configurations/development.rb +31 -0
- data/samples/blog/configurations/mapping.rb +23 -0
- data/samples/blog/configurations/production.rb +30 -0
- data/samples/blog/doc/EMTPY +0 -0
- data/samples/blog/lib/application.rb +5 -0
- data/samples/blog/models/comment.rb +14 -0
- data/samples/blog/models/entry.rb +14 -0
- data/samples/blog/public/css/site.css +2 -0
- data/samples/blog/public/javascript/site.js +13 -0
- data/samples/blog/schema/migrations/001_initial_schema.rb +17 -0
- data/samples/blog/schema/migrations/002_add_comments.rb +18 -0
- data/samples/blog/schema/migrations/templates/empty.rb.erb +9 -0
- data/samples/blog/startup.rb +6 -0
- data/samples/blog/templates/comment/add.mab +10 -0
- data/samples/blog/templates/comment/list.mab +6 -0
- data/samples/blog/templates/entry/editor.mab +13 -0
- data/samples/blog/templates/entry/list.mab +11 -0
- data/samples/blog/templates/entry/show.mab +9 -0
- data/samples/blog/templates/entry/summary.mab +5 -0
- data/samples/blog/templates/errors/not_found_404.mab +2 -0
- data/samples/blog/templates/errors/server_error_500.mab +2 -0
- data/samples/blog/templates/layouts/default.mab +17 -0
- data/samples/jub/Rakefile +72 -0
- data/samples/jub/bin/waves-console +4 -0
- data/samples/jub/bin/waves-server +4 -0
- data/samples/jub/configurations/development.rb +31 -0
- data/samples/jub/configurations/mapping.rb +18 -0
- data/samples/jub/configurations/production.rb +31 -0
- data/samples/jub/lib/application.rb +5 -0
- data/samples/jub/startup.rb +6 -0
- data/samples/jub/templates/errors/not_found_404.mab +2 -0
- data/samples/jub/templates/errors/server_error_500.mab +2 -0
- data/samples/jub/templates/layouts/default.mab +14 -0
- data/verify/app_generation/helpers.rb +24 -0
- data/verify/app_generation/startup.rb +39 -0
- data/verify/blackboard/blackboard_verify.rb +92 -0
- data/verify/blackboard/helpers.rb +5 -0
- data/verify/configurations/attributes.rb +37 -0
- data/verify/configurations/helpers.rb +1 -0
- data/verify/configurations/rack_integration.rb +29 -0
- data/verify/controllers/base.rb +37 -0
- data/verify/controllers/helpers.rb +13 -0
- data/verify/controllers/interface.rb +51 -0
- data/verify/core/helpers.rb +3 -0
- data/verify/core/utilities.rb +177 -0
- data/verify/foundations/default.rb +86 -0
- data/verify/foundations/default_application/Rakefile +14 -0
- data/verify/foundations/default_application/bin/waves-console +3 -0
- data/verify/foundations/default_application/bin/waves-server +3 -0
- data/verify/foundations/default_application/configurations/development.rb +26 -0
- data/verify/foundations/default_application/configurations/mapping.rb +14 -0
- data/verify/foundations/default_application/configurations/production.rb +30 -0
- data/verify/foundations/default_application/controllers/default.rb +15 -0
- data/verify/foundations/default_application/controllers/loaded.rb +15 -0
- data/verify/foundations/default_application/defaultapplication.db +0 -0
- data/verify/foundations/default_application/helpers/loaded.rb +10 -0
- data/verify/foundations/default_application/lib/application.rb +5 -0
- data/verify/foundations/default_application/models/default.rb +13 -0
- data/verify/foundations/default_application/models/loaded.rb +13 -0
- data/verify/foundations/default_application/schema/migrations/templates/empty.rb.erb +9 -0
- data/verify/foundations/default_application/startup.rb +7 -0
- data/verify/foundations/default_application/templates/errors/not_found_404.mab +2 -0
- data/verify/foundations/default_application/templates/errors/server_error_500.mab +2 -0
- data/verify/foundations/default_application/templates/layouts/default.mab +14 -0
- data/verify/foundations/default_application/views/default.rb +7 -0
- data/verify/foundations/default_application/views/loaded.rb +15 -0
- data/verify/foundations/helpers.rb +1 -0
- data/verify/foundations/simple.rb +25 -0
- data/verify/helpers.rb +76 -0
- data/verify/layers/data_mapper/association_verify.rb +87 -0
- data/verify/layers/default_errors.rb +29 -0
- data/verify/layers/helpers.rb +1 -0
- data/verify/layers/migration.rb +33 -0
- data/verify/layers/sequel/model.rb +41 -0
- data/verify/layers/sequeltest.db +0 -0
- data/verify/mapping/always.rb +19 -0
- data/verify/mapping/filters.rb +65 -0
- data/verify/mapping/handle.rb +24 -0
- data/verify/mapping/helpers.rb +7 -0
- data/verify/mapping/matches.rb +27 -0
- data/verify/mapping/named.rb +29 -0
- data/verify/mapping/options.rb +17 -0
- data/verify/mapping/path.rb +40 -0
- data/verify/mapping/response_proxy.rb +50 -0
- data/verify/mapping/threaded.rb +25 -0
- data/verify/requests/helpers.rb +16 -0
- data/verify/requests/request.rb +73 -0
- data/verify/requests/response.rb +59 -0
- data/verify/requests/session.rb +54 -0
- data/verify/views/helpers.rb +1 -0
- data/verify/views/rendering.rb +34 -0
- data/verify/views/templates/foo.erb +0 -0
- data/verify/views/templates/moo.erb +0 -0
- data/verify/views/templates/moo.mab +0 -0
- metadata +597 -224
- data/lib/utilities/kernel.rb +0 -34
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Module: Waves::Mapping</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Module</strong></td>
|
|
53
|
+
<td class="class-name-in-header">Waves::Mapping</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../../files/lib/mapping/mapping_rb.html">
|
|
59
|
+
lib/mapping/mapping.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
<a href="../../files/lib/mapping/pretty_urls_rb.html">
|
|
63
|
+
lib/mapping/pretty_urls.rb
|
|
64
|
+
</a>
|
|
65
|
+
<br />
|
|
66
|
+
</td>
|
|
67
|
+
</tr>
|
|
68
|
+
|
|
69
|
+
</table>
|
|
70
|
+
</div>
|
|
71
|
+
<!-- banner header -->
|
|
72
|
+
|
|
73
|
+
<div id="bodyContent">
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
<div id="contextContent">
|
|
78
|
+
|
|
79
|
+
<div id="description">
|
|
80
|
+
<p>
|
|
81
|
+
Mappings in <a href="../Waves.html">Waves</a> are the interface between the
|
|
82
|
+
request dispatcher and your application code. The dispatcher matches each
|
|
83
|
+
request against the mappings to determine a primary action and to collect
|
|
84
|
+
sets of <a href="Mapping.html#M000028">before</a>, <a
|
|
85
|
+
href="Mapping.html#M000029">after</a>, <a
|
|
86
|
+
href="Mapping.html#M000030">wrap</a>, and <a
|
|
87
|
+
href="Mapping.html#M000031">always</a> actions. The dispatcher also looks
|
|
88
|
+
for an exception handler registered in the mappings when attempting a
|
|
89
|
+
rescue.
|
|
90
|
+
</p>
|
|
91
|
+
<p>
|
|
92
|
+
Each mapping associates a block with a set of constraints. Mappings can be
|
|
93
|
+
one of several types:
|
|
94
|
+
</p>
|
|
95
|
+
<ul>
|
|
96
|
+
<li>action (the actual request processing and response)
|
|
97
|
+
|
|
98
|
+
</li>
|
|
99
|
+
<li><a href="Mapping.html#M000036">handle</a> (exception handling)
|
|
100
|
+
|
|
101
|
+
</li>
|
|
102
|
+
<li><a href="Mapping.html#M000028">before</a>
|
|
103
|
+
|
|
104
|
+
</li>
|
|
105
|
+
<li><a href="Mapping.html#M000029">after</a>
|
|
106
|
+
|
|
107
|
+
</li>
|
|
108
|
+
<li><a href="Mapping.html#M000030">wrap</a> (registers its block as both a <a
|
|
109
|
+
href="Mapping.html#M000028">before</a> and <a
|
|
110
|
+
href="Mapping.html#M000029">after</a> action)
|
|
111
|
+
|
|
112
|
+
</li>
|
|
113
|
+
<li><a href="Mapping.html#M000031">always</a> (like an "ensure"
|
|
114
|
+
clause in a rescue)
|
|
115
|
+
|
|
116
|
+
</li>
|
|
117
|
+
</ul>
|
|
118
|
+
<p>
|
|
119
|
+
Actions are registered using <a href="Mapping.html#M000033">path</a>, <a
|
|
120
|
+
href="Mapping.html#M000034">url</a>, or <a
|
|
121
|
+
href="Mapping.html#M000032">map</a>. The other types may be registered
|
|
122
|
+
using methods named <a href="Mapping.html#M000029">after</a> the type.
|
|
123
|
+
</p>
|
|
124
|
+
<p>
|
|
125
|
+
The available constraints are:
|
|
126
|
+
</p>
|
|
127
|
+
<ul>
|
|
128
|
+
<li>a string or regexp that the <a href="Mapping.html#M000033">path</a> or <a
|
|
129
|
+
href="Mapping.html#M000034">url</a> must match
|
|
130
|
+
|
|
131
|
+
</li>
|
|
132
|
+
<li>parameters to match against the HTTP request headers and the Rack-specific
|
|
133
|
+
variables (e.g. ‘rack.url_scheme’)
|
|
134
|
+
|
|
135
|
+
</li>
|
|
136
|
+
<li>an additional hash reserved for settings not related to the Rack request
|
|
137
|
+
(e.g. giving Rack handers special instructions for certain requests. See <a
|
|
138
|
+
href="Mapping.html#M000038">threaded?</a> )
|
|
139
|
+
|
|
140
|
+
</li>
|
|
141
|
+
</ul>
|
|
142
|
+
<p>
|
|
143
|
+
The dispatcher evaluates mapping blocks in an instance of <a
|
|
144
|
+
href="ResponseProxy.html">ResponseProxy</a>, which provides access to
|
|
145
|
+
foundational classes of a <a href="../Waves.html">Waves</a> application
|
|
146
|
+
(i.e. controllers and views)
|
|
147
|
+
</p>
|
|
148
|
+
<h2>Examples</h2>
|
|
149
|
+
<pre>
|
|
150
|
+
resource = '([\w\-]+)'
|
|
151
|
+
name = '([\w\-\_\.\+\@]+)'
|
|
152
|
+
|
|
153
|
+
path %r{^/#{resource}/#{name}/?$} do |resource, name|
|
|
154
|
+
"Hello from a #{resource} named #{name.capitalize}."
|
|
155
|
+
end
|
|
156
|
+
</pre>
|
|
157
|
+
<p>
|
|
158
|
+
In this example, we are using binding regular expressions defined by
|
|
159
|
+
<tt>resource</tt> and <tt>name</tt>. The matches are passed into the block
|
|
160
|
+
as parameters. Thus, this rule, given the URL ’/person/john’
|
|
161
|
+
will return:
|
|
162
|
+
</p>
|
|
163
|
+
<pre>
|
|
164
|
+
Hello from a person named John.
|
|
165
|
+
</pre>
|
|
166
|
+
<p>
|
|
167
|
+
The given block may simple return a string. The content type is inferred
|
|
168
|
+
from the request if possible, otherwise it defaults to
|
|
169
|
+
<tt>text</tt>/<tt>html</tt>.
|
|
170
|
+
</p>
|
|
171
|
+
<pre>
|
|
172
|
+
path '/critters', :method => :post do
|
|
173
|
+
request.content_type
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
/critters # => 'text/html'
|
|
177
|
+
</pre>
|
|
178
|
+
<p>
|
|
179
|
+
In this example, we match against a string and check to make sure that the
|
|
180
|
+
request is a POST. If so, we return the request content_type. The request
|
|
181
|
+
(and response) objects are available from within the block implicitly.
|
|
182
|
+
</p>
|
|
183
|
+
<h1>Invoking <a href="Controllers.html">Controllers</a> and <a href="Views.html">Views</a></h1>
|
|
184
|
+
<p>
|
|
185
|
+
You may invoke a controller or view method for the primary application by
|
|
186
|
+
using the corresponding methods, preceded by the <tt>use</tt> directive.
|
|
187
|
+
</p>
|
|
188
|
+
<h2>Examples</h2>
|
|
189
|
+
<pre>
|
|
190
|
+
path %r{^/#{resource}/#{name}/?$} do |resource, name|
|
|
191
|
+
resource( resource ) do
|
|
192
|
+
controller { find( name ) } | view { | instance | show( resource => instance ) }
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
</pre>
|
|
196
|
+
<p>
|
|
197
|
+
In this example, we take the same rule from above but invoke a controller
|
|
198
|
+
and view method. We use the <tt>resource</tt> directive and the resource
|
|
199
|
+
parameter to set the MVC instances we‘re going to use. This is
|
|
200
|
+
necessary to use the <tt>controller</tt> or <tt>view</tt> methods. Each of
|
|
201
|
+
these take a block as arguments which are evaluated in the context of the
|
|
202
|
+
instance. The <tt>view</tt> method can further take an argument which is
|
|
203
|
+
"piped" from the result of the controller block. This isn‘t
|
|
204
|
+
required, but helps to clarify the request processing. Within a view block,
|
|
205
|
+
a hash may also be passed in to the view method, which is converted into
|
|
206
|
+
instance variables for the view instance. In this example, the
|
|
207
|
+
<tt>show</tt> method is assigned to an instance variable with the same name
|
|
208
|
+
as the resource type.
|
|
209
|
+
</p>
|
|
210
|
+
<p>
|
|
211
|
+
So given the same URL as above - /person/john - what will happen is the
|
|
212
|
+
<tt>find</tt> method for the <tt>Person</tt> controller will be invoked and
|
|
213
|
+
the result passed to the <tt>Person</tt> view‘s <tt>show</tt> method,
|
|
214
|
+
with +@person+ holding the value returned.
|
|
215
|
+
</p>
|
|
216
|
+
<p>
|
|
217
|
+
Crucially, the controller does not need to know what variables the view
|
|
218
|
+
depends on. This is the job of the mapping block, to act as the
|
|
219
|
+
"glue" between the controller and view. The controller and view
|
|
220
|
+
can thus be completely decoupled and become easier to reuse separately.
|
|
221
|
+
</p>
|
|
222
|
+
<pre>
|
|
223
|
+
url 'http://admin.foobar.com:/' do
|
|
224
|
+
resource( :admin ) { view { console } }
|
|
225
|
+
end
|
|
226
|
+
</pre>
|
|
227
|
+
<p>
|
|
228
|
+
In this example, we are using the <tt><a
|
|
229
|
+
href="Mapping.html#M000034">url</a></tt> method to <a
|
|
230
|
+
href="Mapping.html#M000032">map</a> a subdomain of +foobar.com+ to the
|
|
231
|
+
console method of the Admin view. In this case, we did not need a
|
|
232
|
+
controller method, so we simply didn‘t call one.
|
|
233
|
+
</p>
|
|
234
|
+
<h1><a href="Mapping.html">Mapping</a> Modules</h1>
|
|
235
|
+
<p>
|
|
236
|
+
You may encapsulate sets of related rules into modules and simply include
|
|
237
|
+
them into your mapping module. Some rule sets come packaged with <a
|
|
238
|
+
href="../Waves.html">Waves</a>, such as <a
|
|
239
|
+
href="Mapping/PrettyUrls.html">PrettyUrls</a> (rules for matching resources
|
|
240
|
+
using names instead of ids). The simplest way to define such modules for
|
|
241
|
+
reuse is by defining the <tt>included</tt> class method for the rules
|
|
242
|
+
module, and then define the rules using <tt>module_eval</tt>. See the <a
|
|
243
|
+
href="Mapping/PrettyUrls.html">PrettyUrls</a> module for an example of how
|
|
244
|
+
to do this.
|
|
245
|
+
</p>
|
|
246
|
+
<p>
|
|
247
|
+
*Important:* Using pre-packaged mapping rules does not prevent you from
|
|
248
|
+
adding to or overriding these rules. However, order does matter, so you
|
|
249
|
+
should put your own rules ahead of those your may be importing. Also, place
|
|
250
|
+
rules with constraints (for example, rules that require a POST) ahead of
|
|
251
|
+
those with no constraints, otherwise the constrainted rules may never be
|
|
252
|
+
called.
|
|
253
|
+
</p>
|
|
254
|
+
|
|
255
|
+
</div>
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<div id="method-list">
|
|
261
|
+
<h3 class="section-bar">Methods</h3>
|
|
262
|
+
|
|
263
|
+
<div class="name-list">
|
|
264
|
+
<a href="#M000039">[]</a>
|
|
265
|
+
<a href="#M000029">after</a>
|
|
266
|
+
<a href="#M000031">always</a>
|
|
267
|
+
<a href="#M000028">before</a>
|
|
268
|
+
<a href="#M000040">clear</a>
|
|
269
|
+
<a href="#M000036">handle</a>
|
|
270
|
+
<a href="#M000032">map</a>
|
|
271
|
+
<a href="#M000033">path</a>
|
|
272
|
+
<a href="#M000035">root</a>
|
|
273
|
+
<a href="#M000037">threaded</a>
|
|
274
|
+
<a href="#M000038">threaded?</a>
|
|
275
|
+
<a href="#M000034">url</a>
|
|
276
|
+
<a href="#M000030">wrap</a>
|
|
277
|
+
</div>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
<!-- if includes -->
|
|
284
|
+
|
|
285
|
+
<div id="section">
|
|
286
|
+
|
|
287
|
+
<div id="class-list">
|
|
288
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
|
289
|
+
|
|
290
|
+
Module <a href="Mapping/PrettyUrls.html" class="link">Waves::Mapping::PrettyUrls</a><br />
|
|
291
|
+
|
|
292
|
+
</div>
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
<!-- if method_list -->
|
|
301
|
+
<div id="methods">
|
|
302
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
303
|
+
|
|
304
|
+
<div id="method-M000039" class="method-detail">
|
|
305
|
+
<a name="M000039"></a>
|
|
306
|
+
|
|
307
|
+
<div class="method-heading">
|
|
308
|
+
<a href="#M000039" class="method-signature">
|
|
309
|
+
<span class="method-name">[]</span><span class="method-args">( request )</span>
|
|
310
|
+
</a>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<div class="method-description">
|
|
314
|
+
<p>
|
|
315
|
+
Match the given request against the defined rules. This is typically only
|
|
316
|
+
called by a dispatcher object, so you shouldn‘t typically use it
|
|
317
|
+
directly.
|
|
318
|
+
</p>
|
|
319
|
+
<p><a class="source-toggle" href="#"
|
|
320
|
+
onclick="toggleCode('M000039-source');return false;">[Source]</a></p>
|
|
321
|
+
<div class="method-source-code" id="M000039-source">
|
|
322
|
+
<pre>
|
|
323
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 226</span>
|
|
324
|
+
226: <span class="ruby-keyword kw">def</span> <span class="ruby-operator">[]</span>( <span class="ruby-identifier">request</span> )
|
|
325
|
+
227:
|
|
326
|
+
228: <span class="ruby-identifier">rx</span> = { <span class="ruby-identifier">:before</span> =<span class="ruby-operator">></span> [], <span class="ruby-identifier">:after</span> =<span class="ruby-operator">></span> [], <span class="ruby-identifier">:always</span> =<span class="ruby-operator">></span> [], <span class="ruby-identifier">:action</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:handlers</span> =<span class="ruby-operator">></span> [] }
|
|
327
|
+
229:
|
|
328
|
+
230: ( <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:before</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:wrap</span>] ).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
329
|
+
231: <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
330
|
+
232: <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:before</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">matches</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matches</span>
|
|
331
|
+
233: <span class="ruby-keyword kw">end</span>
|
|
332
|
+
234:
|
|
333
|
+
235: <span class="ruby-identifier">mapping</span>.<span class="ruby-identifier">find</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
334
|
+
236: <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:action</span>] = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
335
|
+
237: <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:action</span>]
|
|
336
|
+
238: <span class="ruby-keyword kw">end</span>
|
|
337
|
+
239:
|
|
338
|
+
240: ( <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:after</span>] <span class="ruby-operator">+</span> <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:wrap</span>] ).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
339
|
+
241: <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
340
|
+
242: <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:after</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">matches</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matches</span>
|
|
341
|
+
243: <span class="ruby-keyword kw">end</span>
|
|
342
|
+
244:
|
|
343
|
+
245: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:always</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
344
|
+
246: <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
345
|
+
247: <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:always</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">matches</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matches</span>
|
|
346
|
+
248: <span class="ruby-keyword kw">end</span>
|
|
347
|
+
249:
|
|
348
|
+
250: <span class="ruby-identifier">handlers</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">exception</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
349
|
+
251: <span class="ruby-identifier">matches</span> = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
350
|
+
252: <span class="ruby-identifier">rx</span>[<span class="ruby-identifier">:handlers</span>] <span class="ruby-operator"><<</span> <span class="ruby-identifier">matches</span>.<span class="ruby-identifier">unshift</span>(<span class="ruby-identifier">exception</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">matches</span>
|
|
351
|
+
253: <span class="ruby-keyword kw">end</span>
|
|
352
|
+
254:
|
|
353
|
+
255: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">rx</span>
|
|
354
|
+
256: <span class="ruby-keyword kw">end</span>
|
|
355
|
+
</pre>
|
|
356
|
+
</div>
|
|
357
|
+
</div>
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<div id="method-M000029" class="method-detail">
|
|
361
|
+
<a name="M000029"></a>
|
|
362
|
+
|
|
363
|
+
<div class="method-heading">
|
|
364
|
+
<a href="#M000029" class="method-signature">
|
|
365
|
+
<span class="method-name">after</span><span class="method-args">( path, options = {}, &block )</span>
|
|
366
|
+
</a>
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
<div class="method-description">
|
|
370
|
+
<p>
|
|
371
|
+
Similar to <a href="Mapping.html#M000028">before</a>, except it runs its
|
|
372
|
+
actions <a href="Mapping.html#M000029">after</a> any matching <tt><a
|
|
373
|
+
href="Mapping.html#M000034">url</a></tt> or <tt><a
|
|
374
|
+
href="Mapping.html#M000033">path</a></tt> actions. Note that <a
|
|
375
|
+
href="Mapping.html#M000029">after</a> methods will run even if an exception
|
|
376
|
+
is thrown during processing.
|
|
377
|
+
</p>
|
|
378
|
+
<p><a class="source-toggle" href="#"
|
|
379
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
|
380
|
+
<div class="method-source-code" id="M000029-source">
|
|
381
|
+
<pre>
|
|
382
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 130</span>
|
|
383
|
+
130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after</span>( <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
384
|
+
131: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
|
385
|
+
132: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
|
|
386
|
+
133: <span class="ruby-keyword kw">else</span>
|
|
387
|
+
134: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">path</span>
|
|
388
|
+
135: <span class="ruby-keyword kw">end</span>
|
|
389
|
+
136: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:after</span>] <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span> ]
|
|
390
|
+
137: <span class="ruby-keyword kw">end</span>
|
|
391
|
+
</pre>
|
|
392
|
+
</div>
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
|
|
396
|
+
<div id="method-M000031" class="method-detail">
|
|
397
|
+
<a name="M000031"></a>
|
|
398
|
+
|
|
399
|
+
<div class="method-heading">
|
|
400
|
+
<a href="#M000031" class="method-signature">
|
|
401
|
+
<span class="method-name">always</span><span class="method-args">( path, options = {}, &block )</span>
|
|
402
|
+
</a>
|
|
403
|
+
</div>
|
|
404
|
+
|
|
405
|
+
<div class="method-description">
|
|
406
|
+
<p>
|
|
407
|
+
Like <a href="Mapping.html#M000029">after</a>, but will run even when an
|
|
408
|
+
exception is thrown. Exceptions in <a
|
|
409
|
+
href="Mapping.html#M000031">always</a> mappings are simply logged and
|
|
410
|
+
ignored.
|
|
411
|
+
</p>
|
|
412
|
+
<p><a class="source-toggle" href="#"
|
|
413
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
|
414
|
+
<div class="method-source-code" id="M000031-source">
|
|
415
|
+
<pre>
|
|
416
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 152</span>
|
|
417
|
+
152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">always</span>( <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
418
|
+
153: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
|
419
|
+
154: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
|
|
420
|
+
155: <span class="ruby-keyword kw">else</span>
|
|
421
|
+
156: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">path</span>
|
|
422
|
+
157: <span class="ruby-keyword kw">end</span>
|
|
423
|
+
158: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:always</span>] <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span> ]
|
|
424
|
+
159: <span class="ruby-keyword kw">end</span>
|
|
425
|
+
</pre>
|
|
426
|
+
</div>
|
|
427
|
+
</div>
|
|
428
|
+
</div>
|
|
429
|
+
|
|
430
|
+
<div id="method-M000028" class="method-detail">
|
|
431
|
+
<a name="M000028"></a>
|
|
432
|
+
|
|
433
|
+
<div class="method-heading">
|
|
434
|
+
<a href="#M000028" class="method-signature">
|
|
435
|
+
<span class="method-name">before</span><span class="method-args">( path, options = {}, &block )</span>
|
|
436
|
+
</a>
|
|
437
|
+
</div>
|
|
438
|
+
|
|
439
|
+
<div class="method-description">
|
|
440
|
+
<p>
|
|
441
|
+
If the pattern matches and constraints given by the options hash are
|
|
442
|
+
satisfied, run the block <a href="Mapping.html#M000028">before</a> running
|
|
443
|
+
any <tt><a href="Mapping.html#M000033">path</a></tt> or <tt><a
|
|
444
|
+
href="Mapping.html#M000034">url</a></tt> actions. You can have as many
|
|
445
|
+
<tt><a href="Mapping.html#M000028">before</a></tt> matches as you want -
|
|
446
|
+
they will all run, unless one of them calls redirect, generates an
|
|
447
|
+
unhandled exception, etc.
|
|
448
|
+
</p>
|
|
449
|
+
<p><a class="source-toggle" href="#"
|
|
450
|
+
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
|
451
|
+
<div class="method-source-code" id="M000028-source">
|
|
452
|
+
<pre>
|
|
453
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 119</span>
|
|
454
|
+
119: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">before</span>( <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
455
|
+
120: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
|
456
|
+
121: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
|
|
457
|
+
122: <span class="ruby-keyword kw">else</span>
|
|
458
|
+
123: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">path</span>
|
|
459
|
+
124: <span class="ruby-keyword kw">end</span>
|
|
460
|
+
125: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:before</span>] <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span> ]
|
|
461
|
+
126: <span class="ruby-keyword kw">end</span>
|
|
462
|
+
</pre>
|
|
463
|
+
</div>
|
|
464
|
+
</div>
|
|
465
|
+
</div>
|
|
466
|
+
|
|
467
|
+
<div id="method-M000040" class="method-detail">
|
|
468
|
+
<a name="M000040"></a>
|
|
469
|
+
|
|
470
|
+
<div class="method-heading">
|
|
471
|
+
<a href="#M000040" class="method-signature">
|
|
472
|
+
<span class="method-name">clear</span><span class="method-args">()</span>
|
|
473
|
+
</a>
|
|
474
|
+
</div>
|
|
475
|
+
|
|
476
|
+
<div class="method-description">
|
|
477
|
+
<p>
|
|
478
|
+
Clear all mapping rules
|
|
479
|
+
</p>
|
|
480
|
+
<p><a class="source-toggle" href="#"
|
|
481
|
+
onclick="toggleCode('M000040-source');return false;">[Source]</a></p>
|
|
482
|
+
<div class="method-source-code" id="M000040-source">
|
|
483
|
+
<pre>
|
|
484
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 259</span>
|
|
485
|
+
259: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear</span>
|
|
486
|
+
260: <span class="ruby-ivar">@mapping</span> = <span class="ruby-ivar">@filters</span> = <span class="ruby-ivar">@handlers</span> = <span class="ruby-keyword kw">nil</span>;
|
|
487
|
+
261: <span class="ruby-keyword kw">end</span>
|
|
488
|
+
</pre>
|
|
489
|
+
</div>
|
|
490
|
+
</div>
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
<div id="method-M000036" class="method-detail">
|
|
494
|
+
<a name="M000036"></a>
|
|
495
|
+
|
|
496
|
+
<div class="method-heading">
|
|
497
|
+
<a href="#M000036" class="method-signature">
|
|
498
|
+
<span class="method-name">handle</span><span class="method-args">(exception, options = {}, &block )</span>
|
|
499
|
+
</a>
|
|
500
|
+
</div>
|
|
501
|
+
|
|
502
|
+
<div class="method-description">
|
|
503
|
+
<p>
|
|
504
|
+
Maps an exception handler to a block.
|
|
505
|
+
</p>
|
|
506
|
+
<p><a class="source-toggle" href="#"
|
|
507
|
+
onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
|
|
508
|
+
<div class="method-source-code" id="M000036-source">
|
|
509
|
+
<pre>
|
|
510
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 194</span>
|
|
511
|
+
194: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle</span>(<span class="ruby-identifier">exception</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
512
|
+
195: <span class="ruby-identifier">handlers</span> <span class="ruby-operator"><<</span> [<span class="ruby-identifier">exception</span>,<span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span>]
|
|
513
|
+
196: <span class="ruby-keyword kw">end</span>
|
|
514
|
+
</pre>
|
|
515
|
+
</div>
|
|
516
|
+
</div>
|
|
517
|
+
</div>
|
|
518
|
+
|
|
519
|
+
<div id="method-M000032" class="method-detail">
|
|
520
|
+
<a name="M000032"></a>
|
|
521
|
+
|
|
522
|
+
<div class="method-heading">
|
|
523
|
+
<a href="#M000032" class="method-signature">
|
|
524
|
+
<span class="method-name">map</span><span class="method-args">( path, options = {}, params = {}, &block )</span>
|
|
525
|
+
</a>
|
|
526
|
+
</div>
|
|
527
|
+
|
|
528
|
+
<div class="method-description">
|
|
529
|
+
<p>
|
|
530
|
+
Maps a request to a block. Don‘t use this method directly unless you
|
|
531
|
+
know what you‘re doing. Use <tt><a
|
|
532
|
+
href="Mapping.html#M000033">path</a></tt> or <tt><a
|
|
533
|
+
href="Mapping.html#M000034">url</a></tt> instead.
|
|
534
|
+
</p>
|
|
535
|
+
<p><a class="source-toggle" href="#"
|
|
536
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
|
537
|
+
<div class="method-source-code" id="M000032-source">
|
|
538
|
+
<pre>
|
|
539
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 163</span>
|
|
540
|
+
163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">map</span>( <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
541
|
+
164: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">path</span>
|
|
542
|
+
165: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">Hash</span>
|
|
543
|
+
166: <span class="ruby-identifier">params</span> = <span class="ruby-identifier">options</span>; <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
|
|
544
|
+
167: <span class="ruby-keyword kw">when</span> <span class="ruby-constant">String</span>
|
|
545
|
+
168: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">path</span>
|
|
546
|
+
169: <span class="ruby-keyword kw">end</span>
|
|
547
|
+
170: <span class="ruby-identifier">mapping</span> <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">block</span> ]
|
|
548
|
+
171: <span class="ruby-keyword kw">end</span>
|
|
549
|
+
</pre>
|
|
550
|
+
</div>
|
|
551
|
+
</div>
|
|
552
|
+
</div>
|
|
553
|
+
|
|
554
|
+
<div id="method-M000033" class="method-detail">
|
|
555
|
+
<a name="M000033"></a>
|
|
556
|
+
|
|
557
|
+
<div class="method-heading">
|
|
558
|
+
<a href="#M000033" class="method-signature">
|
|
559
|
+
<span class="method-name">path</span><span class="method-args">( pat, options = {}, params = {}, &block )</span>
|
|
560
|
+
</a>
|
|
561
|
+
</div>
|
|
562
|
+
|
|
563
|
+
<div class="method-description">
|
|
564
|
+
<p>
|
|
565
|
+
Match pattern against the +request.path+, along with satisfying any
|
|
566
|
+
constraints specified by the options hash. If the pattern matches and the
|
|
567
|
+
constraints are satisfied, run the block. Only one <tt><a
|
|
568
|
+
href="Mapping.html#M000033">path</a></tt> or <tt><a
|
|
569
|
+
href="Mapping.html#M000034">url</a></tt> match will be run (the first one).
|
|
570
|
+
</p>
|
|
571
|
+
<p><a class="source-toggle" href="#"
|
|
572
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
|
573
|
+
<div class="method-source-code" id="M000033-source">
|
|
574
|
+
<pre>
|
|
575
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 176</span>
|
|
576
|
+
176: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">path</span>( <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
577
|
+
177: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">pat</span>; <span class="ruby-identifier">map</span>( <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
578
|
+
178: <span class="ruby-keyword kw">end</span>
|
|
579
|
+
</pre>
|
|
580
|
+
</div>
|
|
581
|
+
</div>
|
|
582
|
+
</div>
|
|
583
|
+
|
|
584
|
+
<div id="method-M000035" class="method-detail">
|
|
585
|
+
<a name="M000035"></a>
|
|
586
|
+
|
|
587
|
+
<div class="method-heading">
|
|
588
|
+
<a href="#M000035" class="method-signature">
|
|
589
|
+
<span class="method-name">root</span><span class="method-args">( options = {}, params = {}, &block )</span>
|
|
590
|
+
</a>
|
|
591
|
+
</div>
|
|
592
|
+
|
|
593
|
+
<div class="method-description">
|
|
594
|
+
<p>
|
|
595
|
+
Maps the <a href="Mapping.html#M000035">root</a> of the application to a
|
|
596
|
+
block. If an options hash is specified it must satisfy those constraints in
|
|
597
|
+
order to run the block.
|
|
598
|
+
</p>
|
|
599
|
+
<p><a class="source-toggle" href="#"
|
|
600
|
+
onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
|
|
601
|
+
<div class="method-source-code" id="M000035-source">
|
|
602
|
+
<pre>
|
|
603
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 189</span>
|
|
604
|
+
189: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">root</span>( <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
605
|
+
190: <span class="ruby-identifier">path</span>( <span class="ruby-regexp re">%r{^/?$}</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
606
|
+
191: <span class="ruby-keyword kw">end</span>
|
|
607
|
+
</pre>
|
|
608
|
+
</div>
|
|
609
|
+
</div>
|
|
610
|
+
</div>
|
|
611
|
+
|
|
612
|
+
<div id="method-M000037" class="method-detail">
|
|
613
|
+
<a name="M000037"></a>
|
|
614
|
+
|
|
615
|
+
<div class="method-heading">
|
|
616
|
+
<a href="#M000037" class="method-signature">
|
|
617
|
+
<span class="method-name">threaded</span><span class="method-args">( pat, options = {}, params = {}, &block)</span>
|
|
618
|
+
</a>
|
|
619
|
+
</div>
|
|
620
|
+
|
|
621
|
+
<div class="method-description">
|
|
622
|
+
<p>
|
|
623
|
+
Maps a request to a block that will be executed within it‘s own
|
|
624
|
+
thread. This is especially useful when you‘re running with an event
|
|
625
|
+
driven server like thin or ebb, and this block is going to take a
|
|
626
|
+
relatively long time.
|
|
627
|
+
</p>
|
|
628
|
+
<p><a class="source-toggle" href="#"
|
|
629
|
+
onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
|
|
630
|
+
<div class="method-source-code" id="M000037-source">
|
|
631
|
+
<pre>
|
|
632
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 202</span>
|
|
633
|
+
202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">threaded</span>( <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
634
|
+
203: <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:threaded</span>] = <span class="ruby-keyword kw">true</span>
|
|
635
|
+
204: <span class="ruby-identifier">map</span>( <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
636
|
+
205: <span class="ruby-keyword kw">end</span>
|
|
637
|
+
</pre>
|
|
638
|
+
</div>
|
|
639
|
+
</div>
|
|
640
|
+
</div>
|
|
641
|
+
|
|
642
|
+
<div id="method-M000038" class="method-detail">
|
|
643
|
+
<a name="M000038"></a>
|
|
644
|
+
|
|
645
|
+
<div class="method-heading">
|
|
646
|
+
<a href="#M000038" class="method-signature">
|
|
647
|
+
<span class="method-name">threaded?</span><span class="method-args">( request )</span>
|
|
648
|
+
</a>
|
|
649
|
+
</div>
|
|
650
|
+
|
|
651
|
+
<div class="method-description">
|
|
652
|
+
<p>
|
|
653
|
+
Determines whether the request should be handled in a separate thread. This
|
|
654
|
+
is used by event driven servers like thin and ebb, and is most useful for
|
|
655
|
+
those methods that take a long time to complete, like for example upload
|
|
656
|
+
processes. E.g.:
|
|
657
|
+
</p>
|
|
658
|
+
<pre>
|
|
659
|
+
threaded("/upload", :method => :post) do
|
|
660
|
+
handle_upload
|
|
661
|
+
end
|
|
662
|
+
</pre>
|
|
663
|
+
<p>
|
|
664
|
+
You typically wouldn‘t use this method directly.
|
|
665
|
+
</p>
|
|
666
|
+
<p><a class="source-toggle" href="#"
|
|
667
|
+
onclick="toggleCode('M000038-source');return false;">[Source]</a></p>
|
|
668
|
+
<div class="method-source-code" id="M000038-source">
|
|
669
|
+
<pre>
|
|
670
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 216</span>
|
|
671
|
+
216: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">threaded?</span>( <span class="ruby-identifier">request</span> )
|
|
672
|
+
217: <span class="ruby-identifier">mapping</span>.<span class="ruby-identifier">find</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-identifier">function</span> <span class="ruby-operator">|</span>
|
|
673
|
+
218: <span class="ruby-identifier">match</span> = <span class="ruby-identifier">match</span>( <span class="ruby-identifier">request</span>, <span class="ruby-identifier">options</span>, <span class="ruby-identifier">function</span> )
|
|
674
|
+
219: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:threaded</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">match</span>
|
|
675
|
+
220: <span class="ruby-keyword kw">end</span>
|
|
676
|
+
221: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
|
|
677
|
+
222: <span class="ruby-keyword kw">end</span>
|
|
678
|
+
</pre>
|
|
679
|
+
</div>
|
|
680
|
+
</div>
|
|
681
|
+
</div>
|
|
682
|
+
|
|
683
|
+
<div id="method-M000034" class="method-detail">
|
|
684
|
+
<a name="M000034"></a>
|
|
685
|
+
|
|
686
|
+
<div class="method-heading">
|
|
687
|
+
<a href="#M000034" class="method-signature">
|
|
688
|
+
<span class="method-name">url</span><span class="method-args">( pat, options = {}, params = {}, &block )</span>
|
|
689
|
+
</a>
|
|
690
|
+
</div>
|
|
691
|
+
|
|
692
|
+
<div class="method-description">
|
|
693
|
+
<p>
|
|
694
|
+
Match pattern against the +request.url+, along with satisfying any
|
|
695
|
+
constraints specified by the options hash. If the pattern matches and the
|
|
696
|
+
constraints are satisfied, run the block. Only one <tt><a
|
|
697
|
+
href="Mapping.html#M000033">path</a></tt> or <tt><a
|
|
698
|
+
href="Mapping.html#M000034">url</a></tt> match will be run (the first one).
|
|
699
|
+
</p>
|
|
700
|
+
<p><a class="source-toggle" href="#"
|
|
701
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
|
702
|
+
<div class="method-source-code" id="M000034-source">
|
|
703
|
+
<pre>
|
|
704
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 183</span>
|
|
705
|
+
183: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">url</span>( <span class="ruby-identifier">pat</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">params</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
706
|
+
184: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:url</span>] = <span class="ruby-identifier">pat</span>; <span class="ruby-identifier">map</span>( <span class="ruby-identifier">options</span>, <span class="ruby-identifier">params</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
707
|
+
185: <span class="ruby-keyword kw">end</span>
|
|
708
|
+
</pre>
|
|
709
|
+
</div>
|
|
710
|
+
</div>
|
|
711
|
+
</div>
|
|
712
|
+
|
|
713
|
+
<div id="method-M000030" class="method-detail">
|
|
714
|
+
<a name="M000030"></a>
|
|
715
|
+
|
|
716
|
+
<div class="method-heading">
|
|
717
|
+
<a href="#M000030" class="method-signature">
|
|
718
|
+
<span class="method-name">wrap</span><span class="method-args">( path, options = {}, &block )</span>
|
|
719
|
+
</a>
|
|
720
|
+
</div>
|
|
721
|
+
|
|
722
|
+
<div class="method-description">
|
|
723
|
+
<p>
|
|
724
|
+
Run the action <a href="Mapping.html#M000028">before</a> and <a
|
|
725
|
+
href="Mapping.html#M000029">after</a> the matching <tt><a
|
|
726
|
+
href="Mapping.html#M000034">url</a></tt> or <tt><a
|
|
727
|
+
href="Mapping.html#M000033">path</a></tt> action.
|
|
728
|
+
</p>
|
|
729
|
+
<p><a class="source-toggle" href="#"
|
|
730
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
|
731
|
+
<div class="method-source-code" id="M000030-source">
|
|
732
|
+
<pre>
|
|
733
|
+
<span class="ruby-comment cmt"># File lib/mapping/mapping.rb, line 140</span>
|
|
734
|
+
140: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wrap</span>( <span class="ruby-identifier">path</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
|
735
|
+
141: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">is_a?</span> <span class="ruby-constant">Hash</span>
|
|
736
|
+
142: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">path</span>
|
|
737
|
+
143: <span class="ruby-keyword kw">else</span>
|
|
738
|
+
144: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:path</span>] = <span class="ruby-identifier">path</span>
|
|
739
|
+
145: <span class="ruby-keyword kw">end</span>
|
|
740
|
+
146: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:before</span>] <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span> ]
|
|
741
|
+
147: <span class="ruby-identifier">filters</span>[<span class="ruby-identifier">:after</span>] <span class="ruby-operator"><<</span> [ <span class="ruby-identifier">options</span>, <span class="ruby-identifier">block</span> ]
|
|
742
|
+
148: <span class="ruby-keyword kw">end</span>
|
|
743
|
+
</pre>
|
|
744
|
+
</div>
|
|
745
|
+
</div>
|
|
746
|
+
</div>
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
</div>
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
</div>
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
<div id="validator-badges">
|
|
756
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
757
|
+
</div>
|
|
758
|
+
|
|
759
|
+
</body>
|
|
760
|
+
</html>
|