Created
October 14, 2013 17:23
-
-
Save pablitar/6978976 to your computer and use it in GitHub Desktop.
Porción de un framework de aspectos
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
require_relative '../src/join_point_metodos' | |
class JoinPointMetodosAccessor < JoinPointMetodos | |
def evaluar(metodo) | |
setter = Proc.new { |nombre| nombre + '=' } | |
getter = Proc.new { |nombre| nombre.delete('=') } | |
if is_setter(metodo.name.to_s) | |
self.esta_el_otro_accessor?(getter,metodo) | |
else | |
if could_be_getter(metodo.name.to_s) | |
self.esta_el_otro_accessor?(setter,metodo) | |
end | |
end | |
end | |
def is_setter(method_name) | |
/^[a-z_]([a-zA-Z_0-9]*)=$/.match(method_name) | |
end | |
def could_be_getter(method_name) | |
/^[a-z_]/.match(method_name) | |
end | |
def esta_el_otro_accessor?(estrategiaBusqueda, metodo) | |
todos_los_nombres = metodo.owner.instance_methods(false).collect do |simbolo| simbolo.to_s end | |
return todos_los_nombres.include?(estrategiaBusqueda.call(metodo.name.to_s)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment