Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed from attributes attribute name to send #5

Merged
merged 1 commit into from
Jan 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/gourami/validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def validate_presence(attribute_name, message = nil)
# A block to determine if a given value is unique or not. It receives
# the value and returns true if the value is unique.
def validate_uniqueness(attribute_name, message = nil, &block)
value = attributes[attribute_name]
value = send(attribute_name)
unless block.call(value)
append_error(attribute_name, message || :is_duplicated)
end
Expand Down Expand Up @@ -124,7 +124,7 @@ def validate_color_format(attribute_name, message = nil)
# @param attribute_name [Symbol]
# @param format [Regexp]
def validate_format(attribute_name, format, message = nil)
value = attributes[attribute_name]
value = send(attribute_name)
if value && !(format =~ value)
append_error(attribute_name, message || :is_invalid)
end
Expand All @@ -144,7 +144,7 @@ def validate_length(attribute_name, options = {})

min = options.fetch(:min, nil)
max = options.fetch(:max, nil)
value = attributes[attribute_name]
value = send(attribute_name)

return if options[:allow_blank] && value.blank?

Expand All @@ -166,7 +166,7 @@ def validate_length(attribute_name, options = {})
# @param attribute_name [Symbol]
# @param list [Array]
def validate_inclusion(attribute_name, list, message = nil)
value = attributes[attribute_name]
value = send(attribute_name)
if value && !list.include?(value)
append_error(attribute_name, message || :isnt_listed)
end
Expand All @@ -189,7 +189,7 @@ def validate_inclusion_of_each(attribute_name, list, message = nil)
#
# @param attribute_name [Symbol]
def validate_any(attribute_name, message = nil)
value = attributes[attribute_name]
value = send(attribute_name)
if value && value.empty?
append_error(attribute_name, message || :cant_be_empty)
end
Expand Down