Skip to content

Instantly share code, notes, and snippets.

@rodrigorrch
Last active November 15, 2022 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigorrch/a8499ee37319381262df75267b1b8511 to your computer and use it in GitHub Desktop.
Save rodrigorrch/a8499ee37319381262df75267b1b8511 to your computer and use it in GitHub Desktop.
Estudando padrões
class AbacaxiMaduro
def initialize
[
vitamina_a
vitamina_b
]
end
private
def vitamina_a
end
def vitamina_b
end
end
module FruitRules
OPTIONS = {
abacaxi_verde: AbacaxiVerde,
abacaxi_maduro: AbacaxiMaduro,
abacaxi_estragado: AbacaxiEstragado,
...
}
def self.strategy(kind, status)
OPTIONS.fetch("#{kind}_#{status}")
end
end
# Chama o metodo
FruitRules.strategy('abacaxi', 'maduro')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment