interactorで引数チェックを行いたい
| [Validators for Interactors. In our previous blog post, we talked… | by Manoj M J | reflektive-engineering | Medium](https://medium.com/reflektive-engineering/validators-for-interactors-a0632494e3d5) より |
module InteractorValidations
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def requires(*attributes)
before do
attributes.each do |attribute|
raise ArgumentError.new("Required attribute #{attribute} is missing") if context.public_send(attribute).nil?
end
end
end
end
end