mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
copy edits [ci skip]
This commit is contained in:
parent
c247370cae
commit
ffb9db0247
2 changed files with 13 additions and 14 deletions
|
@ -28,7 +28,7 @@ module ActionDispatch
|
||||||
@env[env_name(key)]
|
@env[env_name(key)]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set the given value for the key mapped to @env.
|
# Sets the given value for the key mapped to @env.
|
||||||
def []=(key, value)
|
def []=(key, value)
|
||||||
@env[env_name(key)] = value
|
@env[env_name(key)] = value
|
||||||
end
|
end
|
||||||
|
@ -36,12 +36,13 @@ module ActionDispatch
|
||||||
def key?(key); @env.key? key; end
|
def key?(key); @env.key? key; end
|
||||||
alias :include? :key?
|
alias :include? :key?
|
||||||
|
|
||||||
|
|
||||||
# Returns the value for the given key mapped to @env.
|
# Returns the value for the given key mapped to @env.
|
||||||
# If the key can’t be found, there are several options:
|
#
|
||||||
# with no other arguments, it will raise an KeyError exception;
|
# If the key is not found and an optional code block is not provided,
|
||||||
# If the optional code block is specified, then that will be run and its
|
# raises a <tt>KeyError</tt> exception.
|
||||||
# result returned.
|
#
|
||||||
|
# If the code block is provided, then it will be run and
|
||||||
|
# its result returned.
|
||||||
def fetch(key, *args, &block)
|
def fetch(key, *args, &block)
|
||||||
@env.fetch env_name(key), *args, &block
|
@env.fetch env_name(key), *args, &block
|
||||||
end
|
end
|
||||||
|
@ -50,7 +51,6 @@ module ActionDispatch
|
||||||
@env.each(&block)
|
@env.each(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# Returns a new Http::Headers instance containing the contents of
|
# Returns a new Http::Headers instance containing the contents of
|
||||||
# <tt>headers_or_env</tt> and the original instance.
|
# <tt>headers_or_env</tt> and the original instance.
|
||||||
def merge(headers_or_env)
|
def merge(headers_or_env)
|
||||||
|
@ -60,7 +60,7 @@ module ActionDispatch
|
||||||
end
|
end
|
||||||
|
|
||||||
# Adds the contents of <tt>headers_or_env</tt> to original instance
|
# Adds the contents of <tt>headers_or_env</tt> to original instance
|
||||||
# entries with duplicate keys are overwritten with the values from
|
# entries; duplicate keys are overwritten with the values from
|
||||||
# <tt>headers_or_env</tt>.
|
# <tt>headers_or_env</tt>.
|
||||||
def merge!(headers_or_env)
|
def merge!(headers_or_env)
|
||||||
headers_or_env.each do |key, value|
|
headers_or_env.each do |key, value|
|
||||||
|
|
|
@ -12,15 +12,14 @@ module ActiveRecord
|
||||||
# of this method is +false+ an <tt>ActiveModel::ForbiddenAttributesError</tt>
|
# of this method is +false+ an <tt>ActiveModel::ForbiddenAttributesError</tt>
|
||||||
# exception is raised.
|
# exception is raised.
|
||||||
#
|
#
|
||||||
# Example:
|
|
||||||
#
|
|
||||||
# cat = Cat.new(name: "Gorby", status: "yawning")
|
# cat = Cat.new(name: "Gorby", status: "yawning")
|
||||||
# cat.attributes # => {"name" => "Gorby", "status" => "yawning"}
|
# cat.attributes # => { "name" => "Gorby", "status" => "yawning" }
|
||||||
# cat.assign_attributes(status: "sleeping")
|
# cat.assign_attributes(status: "sleeping")
|
||||||
# cat.attributes # => {"name" => "Gorby", "status" => "sleeping"}
|
# cat.attributes # => { "name" => "Gorby", "status" => "sleeping" }
|
||||||
#
|
#
|
||||||
# New attributes will be persisted to database when object is saved.
|
# New attributes will be persisted in the database when the object is saved.
|
||||||
# <tt>attributes =</tt> is an alias.
|
#
|
||||||
|
# Aliased to <tt>attributes=</tt>.
|
||||||
def assign_attributes(new_attributes)
|
def assign_attributes(new_attributes)
|
||||||
if !new_attributes.respond_to?(:stringify_keys)
|
if !new_attributes.respond_to?(:stringify_keys)
|
||||||
raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
|
raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."
|
||||||
|
|
Loading…
Reference in a new issue