hackvan said over 5 years ago on Service Objects for API Interactions with Twilio :
Great approach, thanks for share!

olimart PRO said over 5 years ago on Service Objects for API Interactions with Twilio :
Nicely refined and refactored. Should be the default structure in all projects :)

richard_wiltshire PRO said over 5 years ago on Service Objects for API Interactions with Twilio :
Well done! At 5 minutes in, could you please tell me which episode you are referencing? Thanks

David Kimura PRO said over 5 years ago on Service Objects for API Interactions with Twilio :
The services class was done in https://www.driftingruby.com/episodes/rails-api-app-authentication-with-json-web-tokens

steve said over 5 years ago on Service Objects for API Interactions with Twilio :
hi there, Just curious, why the approach of errors and if/unless logic instead of raising an exception of the class invariants are not set? i would think it'd be much simpler to use an exception for this and keep the service logic simpler and easier to test (esp for a more complex service). I remember hearing "experts" (like Sandi Metz) say this was ok to use exceptions for business logic rule errors, and this would seem to be one). Thanks!

David Kimura PRO said over 5 years ago on Service Objects for API Interactions with Twilio :
I think that it depends on the goals of the service object. If it were only internal interactions then this would make sense. However, if the issue was an error with an external api that you've wrapped your service object around, I would probably prefer this method.

Steve Lim said about 4 years ago on Service Objects for API Interactions with Twilio :
class << self
  def call(*arg)
    new(*arg).constructor
  end
end

attr_reader :result
def constructor
  @result = call
  self
end
Could i get some reference or could you explain how this code works?  I am just not familiar with the code above. thanks. 

David Kimura PRO said about 4 years ago on Service Objects for API Interactions with Twilio :
class << self
  def call(*arg)
    ...
  end
end

is the same thing as

def self.call(*arg)
  ...
end

It's a different way of calling a class method. Does that help?

Login to Comment