Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lifo/docrails
Browse files Browse the repository at this point in the history
Conflicts:
	actionpack/lib/action_dispatch/routing/redirection.rb
  • Loading branch information
vijaydev committed Nov 16, 2012
2 parents 8eefdb6 + 1fd008c commit 7b70eee
Show file tree
Hide file tree
Showing 61 changed files with 959 additions and 957 deletions.
18 changes: 9 additions & 9 deletions actionmailer/lib/action_mailer/base.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module ActionMailer
# The block syntax is also useful in providing information specific to a part: # The block syntax is also useful in providing information specific to a part:
# #
# mail(to: user.email) do |format| # mail(to: user.email) do |format|
# format.text(:content_transfer_encoding => "base64") # format.text(content_transfer_encoding: "base64")
# format.html # format.html
# end # end
# #
Expand Down Expand Up @@ -129,12 +129,12 @@ module ActionMailer
# It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt> # It is also possible to set a default host that will be used in all mailers by setting the <tt>:host</tt>
# option as a configuration option in <tt>config/application.rb</tt>: # option as a configuration option in <tt>config/application.rb</tt>:
# #
# config.action_mailer.default_url_options = { :host => "example.com" } # config.action_mailer.default_url_options = { host: "example.com" }
# #
# When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the # When you decide to set a default <tt>:host</tt> for your mailers, then you need to make sure to use the
# <tt>:only_path => false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper # <tt>only_path: false</tt> option when using <tt>url_for</tt>. Since the <tt>url_for</tt> view helper
# will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing # will generate relative URLs by default when a <tt>:host</tt> option isn't explicitly provided, passing
# <tt>:only_path => false</tt> will ensure that absolute URLs are generated. # <tt>only_path: false</tt> will ensure that absolute URLs are generated.
# #
# = Sending mail # = Sending mail
# #
Expand Down Expand Up @@ -246,10 +246,10 @@ module ActionMailer
# You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box, # You can pass in any header value that a <tt>Mail::Message</tt> accepts. Out of the box,
# <tt>ActionMailer::Base</tt> sets the following: # <tt>ActionMailer::Base</tt> sets the following:
# #
# * <tt>:mime_version => "1.0"</tt> # * <tt>mime_version: "1.0"</tt>
# * <tt>:charset => "UTF-8",</tt> # * <tt>charset: "UTF-8",</tt>
# * <tt>:content_type => "text/plain",</tt> # * <tt>content_type: "text/plain",</tt>
# * <tt>:parts_order => [ "text/plain", "text/enriched", "text/html" ]</tt> # * <tt>parts_order: [ "text/plain", "text/enriched", "text/html" ]</tt>
# #
# <tt>parts_order</tt> and <tt>charset</tt> are not actually valid <tt>Mail::Message</tt> header fields, # <tt>parts_order</tt> and <tt>charset</tt> are not actually valid <tt>Mail::Message</tt> header fields,
# but Action Mailer translates them appropriately and sets the correct values. # but Action Mailer translates them appropriately and sets the correct values.
Expand Down Expand Up @@ -665,7 +665,7 @@ def attachments
# #
# The block syntax also allows you to customize the part headers if desired: # The block syntax also allows you to customize the part headers if desired:
# #
# mail(:to => 'mikel@test.lindsaar.net') do |format| # mail(to: 'mikel@test.lindsaar.net') do |format|
# format.text(content_transfer_encoding: "base64") # format.text(content_transfer_encoding: "base64")
# format.html # format.html
# end # end
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/abstract_controller/layouts.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ module AbstractController
# <tt>:only</tt> and <tt>:except</tt> options can be passed to the layout call. For example: # <tt>:only</tt> and <tt>:except</tt> options can be passed to the layout call. For example:
# #
# class WeblogController < ActionController::Base # class WeblogController < ActionController::Base
# layout "weblog_standard", :except => :rss # layout "weblog_standard", except: :rss
# #
# # ... # # ...
# #
Expand All @@ -180,7 +180,7 @@ module AbstractController
# be rendered directly, without wrapping a layout around the rendered view. # be rendered directly, without wrapping a layout around the rendered view.
# #
# Both the <tt>:only</tt> and <tt>:except</tt> condition can accept an arbitrary number of method references, so # Both the <tt>:only</tt> and <tt>:except</tt> condition can accept an arbitrary number of method references, so
# #<tt>:except => [ :rss, :text_only ]</tt> is valid, as is <tt>:except => :rss</tt>. # #<tt>except: [ :rss, :text_only ]</tt> is valid, as is <tt>except: :rss</tt>.
# #
# == Using a different layout in the action render call # == Using a different layout in the action render call
# #
Expand All @@ -192,7 +192,7 @@ module AbstractController
# layout "weblog_standard" # layout "weblog_standard"
# #
# def help # def help
# render :action => "help", :layout => "help" # render action: "help", layout: "help"
# end # end
# end # end
# #
Expand Down
39 changes: 22 additions & 17 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def root(options = {})
# and +:action+ to the controller's action. A pattern can also map # and +:action+ to the controller's action. A pattern can also map
# wildcard segments (globs) to params: # wildcard segments (globs) to params:
# #
# match 'songs/*category/:title' => 'songs#show' # match 'songs/*category/:title', to: 'songs#show'
# #
# # 'songs/rock/classic/stairway-to-heaven' sets # # 'songs/rock/classic/stairway-to-heaven' sets
# # params[:category] = 'rock/classic' # # params[:category] = 'rock/classic'
Expand All @@ -315,10 +315,14 @@ def root(options = {})
# A pattern can also point to a +Rack+ endpoint i.e. anything that # A pattern can also point to a +Rack+ endpoint i.e. anything that
# responds to +call+: # responds to +call+:
# #
# match 'photos/:id' => lambda {|hash| [200, {}, "Coming soon"] } # match 'photos/:id', to: lambda {|hash| [200, {}, "Coming soon"] }
# match 'photos/:id' => PhotoRackApp # match 'photos/:id', to: PhotoRackApp
# # Yes, controller actions are just rack endpoints # # Yes, controller actions are just rack endpoints
# match 'photos/:id' => PhotosController.action(:show) # match 'photos/:id', to: PhotosController.action(:show)
#
# Because request various HTTP verbs with a single action has security
# implications, is recommendable use HttpHelpers[rdoc-ref:HttpHelpers]
# instead +match+
# #
# === Options # === Options
# #
Expand All @@ -336,7 +340,7 @@ def root(options = {})
# [:module] # [:module]
# The namespace for :controller. # The namespace for :controller.
# #
# match 'path' => 'c#a', module: 'sekret', controller: 'posts' # match 'path', to: 'c#a', module: 'sekret', controller: 'posts'
# #=> Sekret::PostsController # #=> Sekret::PostsController
# #
# See <tt>Scoping#namespace</tt> for its scope equivalent. # See <tt>Scoping#namespace</tt> for its scope equivalent.
Expand All @@ -347,8 +351,9 @@ def root(options = {})
# [:via] # [:via]
# Allowed HTTP verb(s) for route. # Allowed HTTP verb(s) for route.
# #
# match 'path' => 'c#a', via: :get # match 'path', to: 'c#a', via: :get
# match 'path' => 'c#a', via: [:get, :post] # match 'path', to: 'c#a', via: [:get, :post]
# match 'path', to: 'c#a', via: :all
# #
# [:to] # [:to]
# Points to a +Rack+ endpoint. Can be an object that responds to # Points to a +Rack+ endpoint. Can be an object that responds to
Expand All @@ -364,14 +369,14 @@ def root(options = {})
# <tt>resource(s)</tt> block. For example: # <tt>resource(s)</tt> block. For example:
# #
# resource :bar do # resource :bar do
# match 'foo' => 'c#a', on: :member, via: [:get, :post] # match 'foo', to: 'c#a', on: :member, via: [:get, :post]
# end # end
# #
# Is equivalent to: # Is equivalent to:
# #
# resource :bar do # resource :bar do
# member do # member do
# match 'foo' => 'c#a', via: [:get, :post] # match 'foo', to: 'c#a', via: [:get, :post]
# end # end
# end # end
# #
Expand All @@ -384,7 +389,7 @@ def root(options = {})
# class Blacklist # class Blacklist
# def matches?(request) request.remote_ip == '1.2.3.4' end # def matches?(request) request.remote_ip == '1.2.3.4' end
# end # end
# match 'path' => 'c#a', constraints: Blacklist.new # match 'path', to: 'c#a', constraints: Blacklist.new
# #
# See <tt>Scoping#constraints</tt> for more examples with its scope # See <tt>Scoping#constraints</tt> for more examples with its scope
# equivalent. # equivalent.
Expand All @@ -393,7 +398,7 @@ def root(options = {})
# Sets defaults for parameters # Sets defaults for parameters
# #
# # Sets params[:format] to 'jpg' by default # # Sets params[:format] to 'jpg' by default
# match 'path' => 'c#a', defaults: { format: 'jpg' } # match 'path', to: 'c#a', defaults: { format: 'jpg' }
# #
# See <tt>Scoping#defaults</tt> for its scope equivalent. # See <tt>Scoping#defaults</tt> for its scope equivalent.
# #
Expand All @@ -402,7 +407,7 @@ def root(options = {})
# false, the pattern matches any request prefixed with the given path. # false, the pattern matches any request prefixed with the given path.
# #
# # Matches any request starting with 'path' # # Matches any request starting with 'path'
# match 'path' => 'c#a', anchor: false # match 'path', to: 'c#a', anchor: false
# #
# [:format] # [:format]
# Allows you to specify the default value for optional +format+ # Allows you to specify the default value for optional +format+
Expand Down Expand Up @@ -499,39 +504,39 @@ def define_generate_prefix(app, name)


module HttpHelpers module HttpHelpers
# Define a route that only recognizes HTTP GET. # Define a route that only recognizes HTTP GET.
# For supported arguments, see <tt>Base#match</tt>. # For supported arguments, see match[rdoc-ref:Base#match]
# #
# get 'bacon', to: 'food#bacon' # get 'bacon', to: 'food#bacon'
def get(*args, &block) def get(*args, &block)
map_method(:get, args, &block) map_method(:get, args, &block)
end end


# Define a route that only recognizes HTTP POST. # Define a route that only recognizes HTTP POST.
# For supported arguments, see <tt>Base#match</tt>. # For supported arguments, see match[rdoc-ref:Base#match]
# #
# post 'bacon', to: 'food#bacon' # post 'bacon', to: 'food#bacon'
def post(*args, &block) def post(*args, &block)
map_method(:post, args, &block) map_method(:post, args, &block)
end end


# Define a route that only recognizes HTTP PATCH. # Define a route that only recognizes HTTP PATCH.
# For supported arguments, see <tt>Base#match</tt>. # For supported arguments, see match[rdoc-ref:Base#match]
# #
# patch 'bacon', to: 'food#bacon' # patch 'bacon', to: 'food#bacon'
def patch(*args, &block) def patch(*args, &block)
map_method(:patch, args, &block) map_method(:patch, args, &block)
end end


# Define a route that only recognizes HTTP PUT. # Define a route that only recognizes HTTP PUT.
# For supported arguments, see <tt>Base#match</tt>. # For supported arguments, see match[rdoc-ref:Base#match]
# #
# put 'bacon', to: 'food#bacon' # put 'bacon', to: 'food#bacon'
def put(*args, &block) def put(*args, &block)
map_method(:put, args, &block) map_method(:put, args, &block)
end end


# Define a route that only recognizes HTTP DELETE. # Define a route that only recognizes HTTP DELETE.
# For supported arguments, see <tt>Base#match</tt>. # For supported arguments, see match[rdoc-ref:Base#match]
# #
# delete 'broccoli', to: 'food#broccoli' # delete 'broccoli', to: 'food#broccoli'
def delete(*args, &block) def delete(*args, &block)
Expand Down
4 changes: 4 additions & 0 deletions activemodel/lib/active_model/secure_password.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module ClassMethods
# you wish to turn off validations, pass <tt>validations: false</tt> as an # you wish to turn off validations, pass <tt>validations: false</tt> as an
# argument. You can add more validations by hand if need be. # argument. You can add more validations by hand if need be.
# #
# If you don't need the confirmation validation, just don't set any
# value to the password_confirmation attribute and the the validation
# will not be triggered.
#
# You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password: # You need to add bcrypt-ruby (~> 3.0.0) to Gemfile to use #has_secure_password:
# #
# gem 'bcrypt-ruby', '~> 3.0.0' # gem 'bcrypt-ruby', '~> 3.0.0'
Expand Down
36 changes: 18 additions & 18 deletions activerecord/lib/active_record/aggregations.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def clear_aggregation_cache #:nodoc:
# the database). # the database).
# #
# class Customer < ActiveRecord::Base # class Customer < ActiveRecord::Base
# composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) # composed_of :balance, class_name: "Money", mapping: %w(balance amount)
# composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] # composed_of :address, mapping: [ %w(address_street street), %w(address_city city) ]
# end # end
# #
# The customer class now has the following methods to manipulate the value objects: # The customer class now has the following methods to manipulate the value objects:
Expand Down Expand Up @@ -138,15 +138,15 @@ def clear_aggregation_cache #:nodoc:
# #
# class NetworkResource < ActiveRecord::Base # class NetworkResource < ActiveRecord::Base
# composed_of :cidr, # composed_of :cidr,
# :class_name => 'NetAddr::CIDR', # class_name: 'NetAddr::CIDR',
# :mapping => [ %w(network_address network), %w(cidr_range bits) ], # mapping: [ %w(network_address network), %w(cidr_range bits) ],
# :allow_nil => true, # allow_nil: true,
# :constructor => Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") }, # constructor: Proc.new { |network_address, cidr_range| NetAddr::CIDR.create("#{network_address}/#{cidr_range}") },
# :converter => Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) } # converter: Proc.new { |value| NetAddr::CIDR.create(value.is_a?(Array) ? value.join('/') : value) }
# end # end
# #
# # This calls the :constructor # # This calls the :constructor
# network_resource = NetworkResource.new(:network_address => '192.168.0.1', :cidr_range => 24) # network_resource = NetworkResource.new(network_address: '192.168.0.1', cidr_range: 24)
# #
# # These assignments will both use the :converter # # These assignments will both use the :converter
# network_resource.cidr = [ '192.168.2.1', 8 ] # network_resource.cidr = [ '192.168.2.1', 8 ]
Expand All @@ -165,7 +165,7 @@ def clear_aggregation_cache #:nodoc:
# by specifying an instance of the value object in the conditions hash. The following example # by specifying an instance of the value object in the conditions hash. The following example
# finds all customers with +balance_amount+ equal to 20 and +balance_currency+ equal to "USD": # finds all customers with +balance_amount+ equal to 20 and +balance_currency+ equal to "USD":
# #
# Customer.where(:balance => Money.new(20, "USD")).all # Customer.where(balance: Money.new(20, "USD")).all
# #
module ClassMethods module ClassMethods
# Adds reader and writer methods for manipulating a value object: # Adds reader and writer methods for manipulating a value object:
Expand Down Expand Up @@ -197,17 +197,17 @@ module ClassMethods
# can return nil to skip the assignment. # can return nil to skip the assignment.
# #
# Option examples: # Option examples:
# composed_of :temperature, :mapping => %w(reading celsius) # composed_of :temperature, mapping: %w(reading celsius)
# composed_of :balance, :class_name => "Money", :mapping => %w(balance amount), # composed_of :balance, class_name: "Money", mapping: %w(balance amount),
# :converter => Proc.new { |balance| balance.to_money } # converter: Proc.new { |balance| balance.to_money }
# composed_of :address, :mapping => [ %w(address_street street), %w(address_city city) ] # composed_of :address, mapping: [ %w(address_street street), %w(address_city city) ]
# composed_of :gps_location # composed_of :gps_location
# composed_of :gps_location, :allow_nil => true # composed_of :gps_location, allow_nil: true
# composed_of :ip_address, # composed_of :ip_address,
# :class_name => 'IPAddr', # class_name: 'IPAddr',
# :mapping => %w(ip to_i), # mapping: %w(ip to_i),
# :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) }, # constructor: Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) },
# :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) } # converter: Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) }
# #
def composed_of(part_id, options = {}) def composed_of(part_id, options = {})
options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter) options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter)
Expand Down
Loading

0 comments on commit 7b70eee

Please sign in to comment.