patreon-ruby
patreon-ruby copied to clipboard
API v2
Update Ruby lib to APIv2.
The generation code lives in https://github.com/Patreon/patreon_py/pull/18680
Note to reviewer
It should be easier to look at each commit individually.
Inspiration: https://github.com/Patreon/patreon-python/pull/28
Although this Enum
utility comes from an external source, I'm also not convinced that const_missing
is the right way to implement enums.
The instance-variant of const_missing
, which is the much more popular method_missing
, has a companion method called Object#respond_to_missing?
. It's meant to act as a fallback for respond_to?
. There's no exact const-variant of respond_to_missing?
, but one way to work around it is to turn this model inside out: instead of using const_missing
to return a value for a constant that does not otherwise exist, use const_set
to define a constant once. For enumerating all constants — something that methods like each
, all
, all_to_hash
rely on — either the built-in Module#constants
can serve that purpose, or, to keep them separate from other non-code-gen'd constants, we can maintain an array of @@enum_constants
.
Although this Enum utility comes from an external source, I'm also not convinced that const_missing is the right way to implement enums.
Do you think it is worth creating a separate PR to address that? Also wondering if there is a ruby gem that we could want to use.
Yes, the author of that snippet has created a separate ruby-enum
gem that does this right.
Edit: Yes, this can be addressed in another PR.
I assume all changes to README.md
here will also be ported over to its template source?
I assume all changes to README.md here will also be ported over to its template source?
Yep! (Thanks for the reminder 😉)