class MacFormatValidator

Public Instance Methods

validate_each(record, attribute, value) click to toggle source
# File lib/mac_format/mac_format_validator.rb, line 2
def validate_each(record, attribute, value)
  value = format_value!(record, attribute, value)
rescue ArgumentError
  record.errors[attribute] << (options[:message] || "is invalid")
end

Private Instance Methods

format_value!(record, attribute, value) click to toggle source
# File lib/mac_format/mac_format_validator.rb, line 10
def format_value!(record, attribute, value)
  record.send("#{ attribute }=", (value || '').to_mac)
end