Last active
February 9, 2016 03:38
-
-
Save Charlyzzz/823c95eb07f7ad077300 to your computer and use it in GitHub Desktop.
This file contains 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 Validations | |
@catch_next_method = false | |
def validate(*validations) | |
@validations = validations | |
@catch_next_method = true | |
end | |
def method_added(method_name) | |
if @catch_next_method then | |
@catch_next_method = false | |
alias_method :"_#{method_name.to_s}", method_name | |
###Hacer algo | |
end | |
end | |
end | |
#Ejemplo | |
class StatusRequestType | |
extend Validations | |
validate :registration | |
def fulfill_for(user, request) | |
Bot.send_to(user.id, "#{user.subscribed ? 'Te' : 'No te'} encontrás suscripto") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment