From e5ac6c8753dc11a1f9869c4fe48a11dc8a32280d Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sun, 4 May 2014 10:40:16 +0530 Subject: Fix Formatting in AR Readme Don't make free form text appear in code blocks [ci skip] --- activerecord/README.rdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc index e04abe9b37..56be7b9598 100644 --- a/activerecord/README.rdoc +++ b/activerecord/README.rdoc @@ -20,8 +20,8 @@ A short rundown of some of the major features: class Product < ActiveRecord::Base end - The Product class is automatically mapped to the table named "products", - which might look like this: +The Product class is automatically mapped to the table named "products", +which might look like this: CREATE TABLE products ( id int(11) NOT NULL auto_increment, -- cgit v1.2.3 From 43fbdbae17744458d71262836b451d68427bd98d Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 7 May 2014 11:09:33 -0500 Subject: [ci skip] document type_cast_for_write --- activerecord/lib/active_record/connection_adapters/column.rb | 2 ++ .../lib/active_record/connection_adapters/postgresql/column.rb | 3 +++ 2 files changed, 5 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index 187eefb9e4..38efebeaf3 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -72,6 +72,8 @@ module ActiveRecord end # Casts a Ruby value to something appropriate for writing to the database. + # Numeric columns will typecast boolean and string to appropriate numeric + # values. def type_cast_for_write(value) return value unless number? diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb index 2cbcd5fd50..3558a641e2 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb @@ -98,6 +98,9 @@ module ActiveRecord end end + # Casts a Ruby value to something appropriate for writing to Postgresql. + # see ActiveRecord::ConnectionAdapters::Class#type_cast_for_write + # see ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Type def type_cast_for_write(value) if @oid_type.respond_to?(:type_cast_for_write) @oid_type.type_cast_for_write(value) -- cgit v1.2.3 From bbfb40a914e3c2bc461da90548471e9daaadbd80 Mon Sep 17 00:00:00 2001 From: schneems Date: Wed, 7 May 2014 11:50:12 -0500 Subject: [ci skip] document ActionDispatch::HTTP::Headers --- actionpack/lib/action_dispatch/http/headers.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index 2666cd4b0a..afaace511a 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -1,5 +1,11 @@ module ActionDispatch module Http + # Provides access to the request's HTTP headers from the environment + # for example: + # + # env = { "CONTENT_TYPE" => "text/plain" } + # headers = ActionDispatch::Http::Headers.new(env) + # headers["Content-Type"] # => "text/plain" class Headers CGI_VARIABLES = %w( CONTENT_TYPE CONTENT_LENGTH -- cgit v1.2.3 From cb6622f455343bb9eddefabc2386dc7858de2e53 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 8 May 2014 18:24:38 +0000 Subject: copy edits [ci skip] --- actionpack/lib/action_dispatch/http/headers.rb | 3 +-- .../lib/active_record/connection_adapters/postgresql/column.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index afaace511a..29cd6a0c27 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -1,7 +1,6 @@ module ActionDispatch module Http - # Provides access to the request's HTTP headers from the environment - # for example: + # Provides access to the request's HTTP headers from the environment. # # env = { "CONTENT_TYPE" => "text/plain" } # headers = ActionDispatch::Http::Headers.new(env) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb index 3558a641e2..1d22b56964 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/column.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/column.rb @@ -98,7 +98,7 @@ module ActiveRecord end end - # Casts a Ruby value to something appropriate for writing to Postgresql. + # Casts a Ruby value to something appropriate for writing to PostgreSQL. # see ActiveRecord::ConnectionAdapters::Class#type_cast_for_write # see ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Type def type_cast_for_write(value) -- cgit v1.2.3 From a923375e797664d2fa7d1a933572fd11431dfaf1 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 9 May 2014 00:04:12 +0530 Subject: fix formatting errors [ci skip] --- activerecord/README.rdoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc index 56be7b9598..335f0e083f 100644 --- a/activerecord/README.rdoc +++ b/activerecord/README.rdoc @@ -19,7 +19,9 @@ A short rundown of some of the major features: class Product < ActiveRecord::Base end - + + {Learn more}[link:classes/ActiveRecord/Base.html] + The Product class is automatically mapped to the table named "products", which might look like this: @@ -29,11 +31,9 @@ which might look like this: PRIMARY KEY (id) ); - This would also define the following accessors: `Product#name` and - `Product#name=(new_name)` - - {Learn more}[link:classes/ActiveRecord/Base.html] - +This would also define the following accessors: `Product#name` and +`Product#name=(new_name)`. + * Associations between objects defined by simple class methods. -- cgit v1.2.3 From aabbf07d003d78a685c0cdcb8e8f9e7fbb02361c Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 9 May 2014 11:29:29 -0500 Subject: [ci skip] doc Http::Headers methods --- actionpack/lib/action_dispatch/http/headers.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index 29cd6a0c27..cd133d6b99 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -19,14 +19,16 @@ module ActionDispatch include Enumerable attr_reader :env - def initialize(env = {}) + def initialize(env = {}) # :nodoc: @env = env end + # Returns the value for the given key mapped to @env. def [](key) @env[env_name(key)] end + # Set the given value for the key mapped to @env. def []=(key, value) @env[env_name(key)] = value end @@ -34,6 +36,12 @@ module ActionDispatch 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. def fetch(key, *args, &block) @env.fetch env_name(key), *args, &block end @@ -42,12 +50,18 @@ module ActionDispatch @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) headers = Http::Headers.new(env.dup) headers.merge!(headers_or_env) headers end + # Adds the contents of headers_or_env to original instance + # entries with duplicate keys are overwritten with the values from + # headers_or_env. def merge!(headers_or_env) headers_or_env.each do |key, value| self[env_name(key)] = value @@ -55,6 +69,8 @@ module ActionDispatch end private + # Converts a HTTP header name to an environment variable name if it is + # not contained within the headers hash. def env_name(key) key = key.to_s if key =~ HTTP_HEADER -- cgit v1.2.3 From 7063e254bf2a24cda7d7f3e07ba50ac1b44a8d2f Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 9 May 2014 11:50:35 -0500 Subject: [ci skip] doc ActiveSupport::TimeWithZone#to_s Current docs are wrong. Does not accept strftime inputs. --- activesupport/lib/active_support/time_with_zone.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index c25c97cfa8..f2a2f3c3db 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -185,8 +185,11 @@ module ActiveSupport end alias_method :rfc822, :rfc2822 - # :db format outputs time in UTC; all others output time in local. - # Uses TimeWithZone's +strftime+, so %Z and %z work correctly. + # Returns a string of the object's date and time. + # Accepts an optional format: + # * :default - default value, mimics Ruby 1.9 Time#to_s format. + # * :db - format outputs time in UTC :db time. See Time#to_formatted_s(:db). + # * Any key in Time::DATE_FORMATS can be used. See active_support/core_ext/time/conversions.rb. def to_s(format = :default) if format == :db utc.to_s(format) -- cgit v1.2.3 From c247370cae6ce681648b8272bf18562addea2353 Mon Sep 17 00:00:00 2001 From: schneems Date: Fri, 9 May 2014 17:37:11 -0500 Subject: [ci skip] add example to AR#assign_attributes --- activerecord/lib/active_record/attribute_assignment.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/activerecord/lib/active_record/attribute_assignment.rb b/activerecord/lib/active_record/attribute_assignment.rb index 30fa2c8ba5..5007e319da 100644 --- a/activerecord/lib/active_record/attribute_assignment.rb +++ b/activerecord/lib/active_record/attribute_assignment.rb @@ -11,6 +11,16 @@ module ActiveRecord # If the passed hash responds to permitted? method and the return value # 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.assign_attributes(status: "sleeping") + # cat.attributes # => {"name" => "Gorby", "status" => "sleeping"} + # + # New attributes will be persisted to database when object is saved. + # attributes = is an alias. 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." -- cgit v1.2.3 From ffb9db0247084514adc73ae92dfe8d5a3033226b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 10 May 2014 13:44:43 +0000 Subject: copy edits [ci skip] --- actionpack/lib/action_dispatch/http/headers.rb | 16 ++++++++-------- activerecord/lib/active_record/attribute_assignment.rb | 11 +++++------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/actionpack/lib/action_dispatch/http/headers.rb b/actionpack/lib/action_dispatch/http/headers.rb index cd133d6b99..dbf3fe51f5 100644 --- a/actionpack/lib/action_dispatch/http/headers.rb +++ b/actionpack/lib/action_dispatch/http/headers.rb @@ -28,7 +28,7 @@ module ActionDispatch @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 @@ module ActionDispatch 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 @@ module ActionDispatch @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 @@ module ActionDispatch 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 5007e319da..87ecbe54f1 100644 --- a/activerecord/lib/active_record/attribute_assignment.rb +++ b/activerecord/lib/active_record/attribute_assignment.rb @@ -12,15 +12,14 @@ module ActiveRecord # 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." -- cgit v1.2.3