a service object properly. • Make name short but include context, environment and its behaviour • Keep it unambiguous • Ask yourself what is's doing and ask your coworker what does he/she think after just hearing its name.
Interactor 05: 06: def call 07: if user = User.authenticate(context.email, context.password) 08: context.user = user 09: context.token = user.secret_token 10: else 11: context.fail!(message: "authenticate_user.failure") 12: end 13: end 014: end
to Redis or to a file, or turn logging off. By default logging is turned off. Redis to be described... File to be described... Exception wrapping to be described... Uniqueness checking to be described...
|user_attributes| 02: required_keys = [:first_name, :last_name, :email] 03: 04: if (required_keys - user_attributes.keys).empty? 05: user_attributes 06: else 07: raise ':first_name, :last_name and :email must be present' 08: end 09: end