betagouv / betaGouvBot

Automated assistant for beta.gouv.fr administrative tasks on slack.
https://beta.gouv.fr
MIT License
4 stars 10 forks source link

Refactoring #2

Closed bonjourmauko closed 7 years ago

bonjourmauko commented 8 years ago

TL; TR :

La gem sendgrid-ruby utilise à son tour la gem ruby-http-client laquelle, malheureusement, utilise un « catch-all » pour les méthodes non définis :

# Dynamically add segments to the url, then call a method.
# (e.g. client.name.name.get())
#
# * *Args*    :
#   - The args are autmoatically passed in
# * *Returns* :
#   - Client object or Response object
#
def method_missing(name, *args, &_block)
  # Capture the version
  if name.to_s == 'version'
    @version = args[0]
    return _
  end
  # We have reached the end of the method chain, make the API call
  return build_request(name, args) if @methods.include?(name.to_s)
  # Add a segment to the URL
  _(name)
end

Cela dit, donc, include SendGrid dans le scope global de l'application ne peut que générer des effets imprévisibles.

bonjourmauko commented 8 years ago

fixup + rebase

bonjourmauko commented 7 years ago

@Morendil Si cela te paraît plus convenable, je peux éclater le PR en plusieurs de manière à qu'ils soient plus atomiques.

Morendil commented 7 years ago

@maukoquiroga En fait j'aurais surtout besoin qu'on puisse binômer 1h pour comprendre tes choix, et on a peu eu l'occasion ces dernières semaines... J'ai bon espoir que ça se fasse bientôt :)

Morendil commented 7 years ago

Closed via #3