Skip to content

Commit

Permalink
Merge pull request #15894 from sgrif/sg-silence-warning-in-test
Browse files Browse the repository at this point in the history
Silence warning in test
  • Loading branch information
senny committed Jun 24, 2014
2 parents 9ac1ce1 + 40e33ff commit 1a299f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/attribute_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def find_parameter_position(multiparameter_name)
end

class MultiparameterAttribute #:nodoc:
attr_reader :object, :name, :values, :column
attr_reader :object, :name, :values, :cast_type

def initialize(object, name, values)
@object = object
Expand All @@ -126,8 +126,8 @@ def initialize(object, name, values)
def read_value
return if values.values.compact.empty?

@column = object.column_for_attribute(name)
klass = column ? column.klass : nil
@cast_type = object.type_for_attribute(name)
klass = cast_type.klass

if klass == Time
read_time
Expand All @@ -141,7 +141,7 @@ def read_value
private

def instantiate_time_object(set_values)
if object.class.send(:create_time_zone_conversion_attribute?, name, column)
if object.class.send(:create_time_zone_conversion_attribute?, name, cast_type)
Time.zone.local(*set_values)
else
Time.send(object.class.default_timezone, *set_values)
Expand All @@ -151,7 +151,7 @@ def instantiate_time_object(set_values)
def read_time
# If column is a :time (and not :date or :datetime) there is no need to validate if
# there are year/month/day fields
if column.type == :time
if cast_type.type == :time
# if the column is a time set the values to their defaults as January 1, 1970, but only if they're nil
{ 1 => 1970, 2 => 1, 3 => 1 }.each do |key,value|
values[key] ||= value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def convert_time_to_time_zone(value)

module ClassMethods
private
def create_time_zone_conversion_attribute?(name, column)
def create_time_zone_conversion_attribute?(name, cast_type)
time_zone_aware_attributes &&
!self.skip_time_zone_conversion_for_attributes.include?(name.to_sym) &&
(:datetime == column.type)
(:datetime == cast_type.type)
end
end
end
Expand Down

0 comments on commit 1a299f1

Please sign in to comment.