我有一個喜歡將控制器傳遞給服務對象的同事。例如,一個控制器方法可能如下方式: class FooController < ApplicationController
...
def show
Foo.new(self).call
end
...
end
的服務對象是這樣的,那麼: class Foo
attr_reader
我目前正在使用一個服務對象 class ServiceObject
include Devise::Controllers::Helpers
內部的設計助手,但我得到 undefined method `helper_method' for ServiceObject:Class
不知道如何使用內部的這樣一個幫手服務對象?
我正在使用服務對象將條帶付款功能抽象到它自己的類中。我正在使用ryan bates談到的https://gist.github.com/ryanb/4172391這種方法。 class Purchase
def initialize(order)
@order = order
end
def create_customer
customer =