mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@466 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
db6688585f
commit
b40d3c9e62
4 changed files with 7 additions and 7 deletions
|
@ -1203,7 +1203,7 @@ module ActiveRecord #:nodoc:
|
|||
end
|
||||
|
||||
def object_from_yaml(string)
|
||||
return string unless String === string
|
||||
return string unless string.is_a?(String)
|
||||
if has_yaml_encoding_header?(string)
|
||||
begin
|
||||
YAML::load(string)
|
||||
|
|
|
@ -217,21 +217,21 @@ module ActiveRecord
|
|||
|
||||
private
|
||||
def string_to_date(string)
|
||||
return string if Date === string
|
||||
return string if string.is_a?(Date)
|
||||
date_array = ParseDate.parsedate(string)
|
||||
# treat 0000-00-00 as nil
|
||||
Date.new(date_array[0], date_array[1], date_array[2]) rescue nil
|
||||
end
|
||||
|
||||
def string_to_time(string)
|
||||
return string if Time === string
|
||||
return string if string.is_a?(Time)
|
||||
time_array = ParseDate.parsedate(string).compact
|
||||
# treat 0000-00-00 00:00:00 as nil
|
||||
Time.send(Base.default_timezone, *time_array) rescue nil
|
||||
end
|
||||
|
||||
def string_to_dummy_time(string)
|
||||
return string if Time === string
|
||||
return string if string.is_a?(Time)
|
||||
time_array = ParseDate.parsedate(string)
|
||||
# pad the resulting array with dummy date information
|
||||
time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1;
|
||||
|
|
|
@ -166,7 +166,7 @@ class Fixtures < Hash
|
|||
fixtures.each { |fixture| fixture.insert_fixtures }
|
||||
end
|
||||
|
||||
reset_sequences(connection, table_names) if ActiveRecord::ConnectionAdapters::PostgreSQLAdapter === connection
|
||||
reset_sequences(connection, table_names) if connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
||||
|
||||
return fixtures.size > 1 ? fixtures : fixtures.first
|
||||
ensure
|
||||
|
|
|
@ -372,9 +372,9 @@ module ActiveRecord
|
|||
validations = self.class.read_inheritable_attribute(validation_method.to_s)
|
||||
if validations.nil? then return end
|
||||
validations.each do |validation|
|
||||
if Symbol === validation
|
||||
if validation.is_a?(Symbol)
|
||||
self.send(validation)
|
||||
elsif String === validation
|
||||
elsif validation.is_a?(String)
|
||||
eval(validation, binding)
|
||||
elsif validation_block?(validation)
|
||||
validation.call(self)
|
||||
|
|
Loading…
Reference in a new issue