Bạn thiết kế service object ra sao trong Rails? Khi nào nên dùng?
Bạn thiết kế service object ra sao trong Rails? Khi nào nên dùng?
Service Object giúp tách logic phức tạp ra khỏi controller/model, theo nguyên tắc Single Responsibility.
Thiết kế đơn giản:
class PaymentService
def initialize(order)
@order = order
...
middle