ruby on rails - Where should background job logic go -


I am using rail and rushes but it is more of a design question, where real logic with background jobs should go.

I have a class like this:

  class ticket # 1) should the method go here? End   

and a BG job like this:

  Module jobs class Patient # 2) Or should the method go here? End End   

Then there is a method that operates the billing for the ticket. It makes two network calls (one of which will be slow), so it is clear that we need a background job

  def pay_ticket # call stages and other network call end   should go.  

Whether there are some common ideas on fats background jobs on people or if this argument usually remains in the model. Or if it depends on each situation thanks!

It really depends on how you want to cover your code. I'm a strong believer Intel fat is a model design pattern, but it is actually dependent on each developer in any way it seems like circumstances will be cured, so I think my first question is, do you share project Are developing in (i.e. other people will work on this code ?)

If not, then I say in the 'model' through it and possibly keep the logic associated with the nearby model of the source.

If you are, then it may be a little dangerous to expose the argument, but a comment is in fact it is not a big deal.

If you do not want actually to call that method, but you want to follow the OOP / encapsulated approach, you always sub-class the ticket model. You have all the functionality but do not expose the payment method, for example:

  #model / ticket.rb class ticket ... end #lib / PBLTicket. Rb class payable ticket and lieutenant; Ticket deaf payment .... and end   

Just my two cents, but I hope that helps.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -