Skip to content

Instantly share code, notes, and snippets.

@Charlyzzz
Last active February 9, 2016 03:38
Show Gist options
  • Save Charlyzzz/823c95eb07f7ad077300 to your computer and use it in GitHub Desktop.
Save Charlyzzz/823c95eb07f7ad077300 to your computer and use it in GitHub Desktop.
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