0
我的類看起來是這樣的實例方法...類方法VS在這個特殊的代碼
class ThirdPartyServiceImport
def posts
execute!('12313', 'EFewfeHUIfaieuh8328')
end
def comments
execute!('333434', 'EwaefawefFewfeHUIh8328')
end
private
def execute!(identifier, key)
client = ThirdPartyClient.new(key)
client.run_query(identifier: identifier)
end
end
我應該使用類的方法?如果是這樣,爲什麼?
此代碼負責擊中第三方API並從中導入內容。對於這裏的例子,我只是假裝我的方法將返回的內容將是帖子和評論。
此內容是我的應用程序依賴的數據,並定期使用這些方法/此類將用於刷新數據。
這段代碼實際上做了什麼? – Linuxios
@Linuxios更新。 – user3084728