5 ms·
Great thoughts! > I'd like a way to make them all noops Sure! There's a default failure callback that gets called when a contract fails. You can just clear th
by egonschiele 14y ago
Great thoughts!
> I'd like a way to make them all noops
Sure! There's a default failure callback that gets called when a contract fails. You can just clear this callback in prod:
if ENV == PRODUCTION
class Contract
def self.failure_callback(data)
# blank
end
end
end
> I'm disappointed that your system seems to offer little more than type checking
Nay! You can write your own contracts to do anything you want. So yes, lambdas are allowed in contracts:
Contract lambda { |x| x.is_valid_email? } => Bool
def save_email(email)
# save an email
end
> with common idioms abbreviated
I provide some common idioms already, but you can make your own abbreviations:
ValidEmail = lambda { |x| x.is_valid_email? }
Contract ValidEmail => Bool
def save_email(email)
Let me know if you have any other questions :)
- pjungwir 14y agoThanks for the clarifications!