This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module N | |
| def foo | |
| puts "N: foo" | |
| super | |
| end | |
| end | |
| module O | |
| def foo | |
| puts "O: foo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Foo | |
| def self.say | |
| p "hello from Foo" | |
| end | |
| end | |
| module Bar | |
| def say | |
| super | |
| p "hello from Bar" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'resolv' | |
| class EmailValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| if Resolv::DNS.new.getresources(value.split("@").last, Resolv::DNS::Resource::IN::MX).empty? | |
| record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
| end | |
| rescue Resolv::ResolvError, Resolv::ResolvTimeout | |
| record.errors[attribute] << (options[:message] || "does not have a valid domain") | |
| end |