提交 a2c84388 编写于 作者: A AvnerCohen

1.9 hash syntax changes.

上级 61c64dc9
...@@ -37,7 +37,7 @@ ActionController ...@@ -37,7 +37,7 @@ ActionController
```ruby ```ruby
{ {
:key => 'posts/1-dasboard-view' key: 'posts/1-dasboard-view'
} }
``` ```
...@@ -49,7 +49,7 @@ ActionController ...@@ -49,7 +49,7 @@ ActionController
```ruby ```ruby
{ {
:key => 'posts/1-dasboard-view' key: 'posts/1-dasboard-view'
} }
``` ```
...@@ -61,7 +61,7 @@ ActionController ...@@ -61,7 +61,7 @@ ActionController
```ruby ```ruby
{ {
:key => 'posts/1-dasboard-view' key: 'posts/1-dasboard-view'
} }
``` ```
...@@ -73,7 +73,7 @@ ActionController ...@@ -73,7 +73,7 @@ ActionController
```ruby ```ruby
{ {
:key => 'posts/1-dasboard-view' key: 'posts/1-dasboard-view'
} }
``` ```
...@@ -85,7 +85,7 @@ ActionController ...@@ -85,7 +85,7 @@ ActionController
```ruby ```ruby
{ {
:path => '/users/1' path: '/users/1'
} }
``` ```
...@@ -97,7 +97,7 @@ ActionController ...@@ -97,7 +97,7 @@ ActionController
```ruby ```ruby
{ {
:path => '/users/1' path: '/users/1'
} }
``` ```
...@@ -114,12 +114,12 @@ ActionController ...@@ -114,12 +114,12 @@ ActionController
```ruby ```ruby
{ {
:controller => "PostsController", controller: "PostsController",
:action => "new", action: "new",
:params => { "action" => "new", "controller" => "posts" }, params: { "action" => "new", "controller" => "posts" },
:format => :html, format: :html,
:method => "GET", method: "GET",
:path => "/posts/new" path: "/posts/new"
} }
``` ```
...@@ -137,15 +137,15 @@ ActionController ...@@ -137,15 +137,15 @@ ActionController
```ruby ```ruby
{ {
:controller => "PostsController", controller: "PostsController",
:action => "index", action: "index",
:params => {"action" => "index", "controller" => "posts"}, params: {"action" => "index", "controller" => "posts"},
:format => :html, format: :html,
:method => "GET", method: "GET",
:path => "/posts", path: "/posts",
:status => 200, status: 200,
:view_runtime => 46.848, view_runtime: 46.848,
:db_runtime => 0.157 db_runtime: 0.157
} }
``` ```
...@@ -170,8 +170,8 @@ INFO. Additional keys may be added by the caller. ...@@ -170,8 +170,8 @@ INFO. Additional keys may be added by the caller.
```ruby ```ruby
{ {
:status => 302, status: 302,
:location => "http://localhost:3000/posts/new" location: "http://localhost:3000/posts/new"
} }
``` ```
...@@ -183,7 +183,7 @@ INFO. Additional keys may be added by the caller. ...@@ -183,7 +183,7 @@ INFO. Additional keys may be added by the caller.
```ruby ```ruby
{ {
:filter => ":halting_filter" filter: ":halting_filter"
} }
``` ```
...@@ -199,8 +199,8 @@ ActionView ...@@ -199,8 +199,8 @@ ActionView
```ruby ```ruby
{ {
:identifier => "/Users/adam/projects/notifications/app/views/posts/index.html.erb", identifier: "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
:layout => "layouts/application" layout: "layouts/application"
} }
``` ```
...@@ -212,7 +212,7 @@ ActionView ...@@ -212,7 +212,7 @@ ActionView
```ruby ```ruby
{ {
:identifier => "/Users/adam/projects/notifications/app/views/posts/_form.html.erb", identifier: "/Users/adam/projects/notifications/app/views/posts/_form.html.erb",
} }
``` ```
...@@ -231,10 +231,10 @@ INFO. The adapters will add their own data as well. ...@@ -231,10 +231,10 @@ INFO. The adapters will add their own data as well.
```ruby ```ruby
{ {
:sql => "SELECT \"posts\".* FROM \"posts\" ", sql: "SELECT \"posts\".* FROM \"posts\" ",
:name => "Post Load", name: "Post Load",
:connection_id => 70307250813140, connection_id: 70307250813140,
:binds => [] binds: []
} }
``` ```
...@@ -265,13 +265,13 @@ ActionMailer ...@@ -265,13 +265,13 @@ ActionMailer
```ruby ```ruby
{ {
:mailer => "Notification", mailer: "Notification",
:message_id => "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail", message_id: "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
:subject => "Rails Guides", subject: "Rails Guides",
:to => ["users@rails.com", "ddh@rails.com"], to: ["users@rails.com", "ddh@rails.com"],
:from => ["me@rails.com"], from: ["me@rails.com"],
:date => Sat, 10 Mar 2012 14:18:09 +0100, date: Sat, 10 Mar 2012 14:18:09 +0100,
:mail=> "..." # ommitted for beverity mail: "..." # ommitted for beverity
} }
``` ```
...@@ -291,13 +291,13 @@ ActionMailer ...@@ -291,13 +291,13 @@ ActionMailer
```ruby ```ruby
{ {
:mailer => "Notification", mailer: "Notification",
:message_id => "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail", message_id: "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
:subject => "Rails Guides", subject: "Rails Guides",
:to => ["users@rails.com", "ddh@rails.com"], to: ["users@rails.com", "ddh@rails.com"],
:from => ["me@rails.com"], from: ["me@rails.com"],
:date => Sat, 10 Mar 2012 14:18:09 +0100, date: Sat, 10 Mar 2012 14:18:09 +0100,
:mail=> "..." # ommitted for beverity mail: "..." # ommitted for beverity
} }
``` ```
...@@ -335,7 +335,7 @@ INFO. Options passed to fetch will be merged with the payload when writing to th ...@@ -335,7 +335,7 @@ INFO. Options passed to fetch will be merged with the payload when writing to th
```ruby ```ruby
{ {
:key => 'name-of-complicated-computation' key: 'name-of-complicated-computation'
} }
``` ```
...@@ -352,7 +352,7 @@ INFO. Options passed to fetch will be merged with the payload. ...@@ -352,7 +352,7 @@ INFO. Options passed to fetch will be merged with the payload.
```ruby ```ruby
{ {
:key => 'name-of-complicated-computation' key: 'name-of-complicated-computation'
} }
``` ```
...@@ -366,7 +366,7 @@ INFO. Cache stores my add their own keys ...@@ -366,7 +366,7 @@ INFO. Cache stores my add their own keys
```ruby ```ruby
{ {
:key => 'name-of-complicated-computation' key: 'name-of-complicated-computation'
} }
``` ```
...@@ -378,7 +378,7 @@ INFO. Cache stores my add their own keys ...@@ -378,7 +378,7 @@ INFO. Cache stores my add their own keys
```ruby ```ruby
{ {
:key => 'name-of-complicated-computation' key: 'name-of-complicated-computation'
} }
``` ```
...@@ -390,7 +390,7 @@ INFO. Cache stores my add their own keys ...@@ -390,7 +390,7 @@ INFO. Cache stores my add their own keys
```ruby ```ruby
{ {
:key => 'name-of-complicated-computation' key: 'name-of-complicated-computation'
} }
``` ```
...@@ -434,7 +434,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a ...@@ -434,7 +434,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a
event.name # => "process_action.action_controller" event.name # => "process_action.action_controller"
event.duration # => 10 (in milliseconds) event.duration # => 10 (in milliseconds)
event.payload # => { :extra => :information } event.payload # => { extra: :information }
Rails.logger.info "#{event} Received!" Rails.logger.info "#{event} Received!"
end end
...@@ -445,7 +445,7 @@ Most times you only care about the data itself. Here is a shortuct to just get t ...@@ -445,7 +445,7 @@ Most times you only care about the data itself. Here is a shortuct to just get t
```ruby ```ruby
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args| ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
data = args.extract_options! data = args.extract_options!
data # { :extra => :information } data # { extra: :information }
``` ```
You may also subscribe to events matching a regular expresssion. This enables you to subscribe to You may also subscribe to events matching a regular expresssion. This enables you to subscribe to
...@@ -468,7 +468,7 @@ as well as the unique ID. All data passed into the `insturment` call will make i ...@@ -468,7 +468,7 @@ as well as the unique ID. All data passed into the `insturment` call will make i
Here's an example: Here's an example:
```ruby ```ruby
ActiveSupport::Notifications.instrument "my.custom.event", :this => :data do ActiveSupport::Notifications.instrument "my.custom.event", this: :data do
# do your custom stuff here # do your custom stuff here
end end
``` ```
...@@ -477,7 +477,7 @@ Now you can listen to this event with: ...@@ -477,7 +477,7 @@ Now you can listen to this event with:
```ruby ```ruby
ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data| ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
puts data.inspect # { :this => :data } puts data.inspect # { this: :data }
end end
``` ```
......
...@@ -64,7 +64,7 @@ On the other hand, big chunks of structured documentation may have a separate "E ...@@ -64,7 +64,7 @@ On the other hand, big chunks of structured documentation may have a separate "E
# #
# Person.exists?(5) # Person.exists?(5)
# Person.exists?('5') # Person.exists?('5')
# Person.exists?(:name => "David") # Person.exists?(name: "David")
# Person.exists?(['name LIKE ?', "%#{query}%"]) # Person.exists?(['name LIKE ?', "%#{query}%"])
``` ```
...@@ -88,7 +88,7 @@ If a line is too long, the comment may be placed on the next line: ...@@ -88,7 +88,7 @@ If a line is too long, the comment may be placed on the next line:
# label(:post, :title, "A short title") # label(:post, :title, "A short title")
# # => <label for="post_title">A short title</label> # # => <label for="post_title">A short title</label>
# #
# label(:post, :title, "A short title", :class => "title_label") # label(:post, :title, "A short title", class: "title_label")
# # => <label for="post_title" class="title_label">A short title</label> # # => <label for="post_title" class="title_label">A short title</label>
``` ```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册