Skip to content

Instantly share code, notes, and snippets.

@joseluistorres
Last active December 28, 2015 16:38
Show Gist options
  • Select an option

  • Save joseluistorres/7529948 to your computer and use it in GitHub Desktop.

Select an option

Save joseluistorres/7529948 to your computer and use it in GitHub Desktop.
Solucion Ducktyping
class BuenFin
def revisa_oferta(objetos_a_validar)
objetos_a_validar.each do |objeto|
objeto.valida_este_objeto
end
end
end
class PantallaPlana
def valida_este_objeto
checar_cuanto_cuesta_y_a_cuantos_meses
end
def checar_cuanto_cuesta_y_a_cuantos_meses
1000
end
end
class Celular4taGeneracion
def valida_este_objeto
checar_si_tiene_garantia
end
def checar_si_tiene_garantia
'maybe' if 'telcel'
end
end
class MueblesCaros
def valida_este_objeto
ver_cuanto_y_porque_tan_caro
end
def ver_cuanto_y_porque_tan_caro
'mucho-muy'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment