diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index cd133d6b9976aa988ce5339942c16cb643c45e9a..dbf3fe51f5035609889712bae8539c4b732f646c 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -28,7 +28,7 @@ def [](key) @env[env_name(key)] end - # Set the given value for the key mapped to @env. + # Sets the given value for the key mapped to @env. def []=(key, value) @env[env_name(key)] = value end @@ -36,12 +36,13 @@ def []=(key, value) def key?(key); @env.key? key; end alias :include? :key? - # 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 optional code block is specified, then that will be run and its - # result returned. + # + # If the key is not found and an optional code block is not provided, + # raises a KeyError exception. + # + # If the code block is provided, then it will be run and + # its result returned. def fetch(key, *args, &block) @env.fetch env_name(key), *args, &block end @@ -50,7 +51,6 @@ def each(&block) @env.each(&block) end - # Returns a new Http::Headers instance containing the contents of # headers_or_env and the original instance. def merge(headers_or_env) @@ -60,7 +60,7 @@ def merge(headers_or_env) end # Adds the contents of headers_or_env to original instance - # entries with duplicate keys are overwritten with the values from + # entries; duplicate keys are overwritten with the values from # headers_or_env. def merge!(headers_or_env) headers_or_env.each do |key, value| diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb index 5007e319da519432dc458756e18bfb54b4b601e4..87ecbe54f1d6c21c672851e619770528d0221495 100644 --- a/activerecord/lib/active_record/attribute_assignment.rb +++ b/activerecord/lib/active_record/attribute_assignment.rb @@ -12,15 +12,14 @@ module AttributeAssignment # of this method is +false+ an ActiveModel::ForbiddenAttributesError # exception is raised. # - # Example: - # # 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.attributes # => {"name" => "Gorby", "status" => "sleeping"} + # cat.attributes # => { "name" => "Gorby", "status" => "sleeping" } + # + # New attributes will be persisted in the database when the object is saved. # - # New attributes will be persisted to database when object is saved. - # attributes = is an alias. + # Aliased to attributes=. def assign_attributes(new_attributes) if !new_attributes.respond_to?(:stringify_keys) raise ArgumentError, "When assigning attributes, you must pass a hash as an argument."