A service that inherit from BaseService should implement method call
Why?
- Adding Syntactic Sugar to Make Rails Service Objects Suck Less
-
If only there were precedence in Ruby for calling something and having it execute itself immediately with the given parameters… oh wait, there is! It’s
Proc#call
What’s Proc#call ?
- Invokes the block, setting the block’s parameters to the values in params using something close to method calling semantics. Returns the value of the last expression evaluated in the block.
- Note that
proc.()invokesproc.call()with the parameters given. It’s syntactic sugar to hide “call”. - For procs created using
lambdaor ->()an error is generated if the wrong number of parameters are passed to the proc. For procs created usingProc.neworKernel.proc, extra parameters are silently discarded and missing parameters are set tonil.
Ref:
Ruby’s Eigenclass Rails Service Objects: A Comprehensive Guide Proc#call
Note này hắn lấy từ GitHub issue qua.