Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. ### Without Dependency Injection approach using
  2.  
  3. # app/controllers/aura_controller.rb
  4. class AuraController < ApplicationController
  5. def show
  6. Aura.where(user_id: user_id)
  7. end
  8. end
  9.  
  10. ### With Dependency Injection approach using
  11.  
  12. # app/controllers/aura_controller.rb
  13. class AuraController < ApplicationController
  14. def show
  15. AuraService.get_aura(user_id)
  16. end
  17. end
  18.  
  19. # app/services/aura_service.rb
  20. class AuraService < BaseService
  21. def get_aura
  22. Aura.where(user_id: user_id)
  23. end
  24. end
  25.  
  26. ## Which helps us with the future refactoring
  27.  
  28. # app/controllers/aura_controller.rb
  29. class AuraController < ApplicationController
  30. def show
  31. AuraService.get_aura(user_id)
  32. end
  33. end
  34.  
  35. # app/services/aura_service.rb
  36. class AuraService < BaseService
  37. def get_aura
  38. call_aura_remote_service(user_id)
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement