You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We found this library as a dependency of another library (snowplow/snowplow-ruby-tracker) that we use in our application. Unfortunately, we also have our own top-level class called Contract, which basically means we have to fork our dependency to remove this gem in order to get things working again. Not great!
If I was in control of everything (the world!), I'd probably consider reworking this gem to use method calls rather than global constants to do its work, so that the external surface area of the API is as small as possible e.g.
classSomethingincludeContracts::BehaviourcontractDouble=>Double# contract is a method from `Contracts::Behaviour`, not a constantdefwem(x);x * 2;endcontractarray_of(Hash)=>nil# array_of is a method from `Contracts::Behaviour`, not a constantdefwibble(args); ...;endend
... however, that's obviously a massive change and I'm not familiar enough with this gem to spot any obvious gotchas, of which there might be many.
However, one way to keep the usage of the gem the same, but not prevent dependencies at any level from defining a Contract class, might be to make these available as refinements that can be explicitly opted-in for classes that want to use verification.
classSomethingusingContracts::BehaviourContractDouble=>Double# same APIdefwem(x);x * 2;endContractArrayOf[Hash]=>nil# same APIdefwibble(args); ...;endendclassOtherThingdeffoo;Contract.first;end# uses existing app-specific `Contract` constant end
Is this something you'd be interested in?
The text was updated successfully, but these errors were encountered:
I have no power to say yes or no to this, and I have no major project that requires such use of refinements, but I just want to say that this is a very cool idea.
Hey there,
Sorry for the late response. I think this is a cool idea as well. I'm largely not maintaining this project -- life has gotten in the way. But if you can open a PR and the tests pass, I'd be happy to merge in.
We found this library as a dependency of another library (snowplow/snowplow-ruby-tracker) that we use in our application. Unfortunately, we also have our own top-level class called
Contract
, which basically means we have to fork our dependency to remove this gem in order to get things working again. Not great!If I was in control of everything (the world!), I'd probably consider reworking this gem to use method calls rather than global constants to do its work, so that the external surface area of the API is as small as possible e.g.
... however, that's obviously a massive change and I'm not familiar enough with this gem to spot any obvious gotchas, of which there might be many.
However, one way to keep the usage of the gem the same, but not prevent dependencies at any level from defining a
Contract
class, might be to make these available as refinements that can be explicitly opted-in for classes that want to use verification.Is this something you'd be interested in?
The text was updated successfully, but these errors were encountered: