Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #9880 from wangjohn/refactoring_attribute_assignment

Refactoring validate_missing_parameters to validate_required_parameters.
  • Loading branch information...
commit 727e2863e5ed8ebfae7d5f4724d1a797b80e59d7 2 parents 6ff36de + 3650edf
@rafaelfranca rafaelfranca authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 activerecord/lib/active_record/attribute_assignment.rb
View
10 activerecord/lib/active_record/attribute_assignment.rb
@@ -81,7 +81,7 @@ def execute_callstack_for_multiparameter_attributes(callstack)
end
def extract_callstack_for_multiparameter_attributes(pairs)
- attributes = { }
+ attributes = {}
pairs.each do |(multiparameter_name, value)|
attribute_name = multiparameter_name.split("(").first
@@ -146,7 +146,7 @@ def read_time
end
else
# else column is a timestamp, so if Date bits were not provided, error
- validate_missing_parameters!([1,2,3])
+ validate_required_parameters!([1,2,3])
# If Date bits were provided but blank, then return nil
return if blank_date_parameter?
@@ -172,14 +172,14 @@ def read_date
def read_other(klass)
max_position = extract_max_param
positions = (1..max_position)
- validate_missing_parameters!(positions)
+ validate_required_parameters!(positions)
set_values = values.values_at(*positions)
klass.new(*set_values)
end
# Checks whether some blank date parameter exists. Note that this is different
- # than the validate_missing_parameters! method, since it just checks for blank
+ # than the validate_required_parameters! method, since it just checks for blank
# positions instead of missing ones, and does not raise in case one blank position
# exists. The caller is responsible to handle the case of this returning true.
def blank_date_parameter?
@@ -187,7 +187,7 @@ def blank_date_parameter?
end
# If some position is not provided, it errors out a missing parameter exception.
- def validate_missing_parameters!(positions)
+ def validate_required_parameters!(positions)
if missing_parameter = positions.detect { |position| !values.key?(position) }
raise ArgumentError.new("Missing Parameter - #{name}(#{missing_parameter})")
end
Please sign in to comment.
Something went wrong with that request. Please try again.