Created
December 9, 2016 20:49
-
-
Save piotr-galas/7a4d254a205db742333f1a6af9c65c7e to your computer and use it in GitHub Desktop.
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 Validator | |
def self.presence(value, *fields) | |
puts value | |
puts fields | |
end | |
end | |
class Product | |
def self.validates(*params) | |
validator_param = params.pop | |
validator_name = validator_param.keys.first | |
validator_value = validator_param.values.first | |
Validator.public_send(validator_name, validator_value, *params) | |
end | |
validates :name, :first_name, presence: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment