Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Without Dependency Injection approach using
- # app/controllers/aura_controller.rb
- class AuraController < ApplicationController
- def show
- Aura.where(user_id: user_id)
- end
- end
- ### With Dependency Injection approach using
- # app/controllers/aura_controller.rb
- class AuraController < ApplicationController
- def show
- AuraService.get_aura(user_id)
- end
- end
- # app/services/aura_service.rb
- class AuraService < BaseService
- def get_aura
- Aura.where(user_id: user_id)
- end
- end
- ## Which helps us with the future refactoring
- # app/controllers/aura_controller.rb
- class AuraController < ApplicationController
- def show
- AuraService.get_aura(user_id)
- end
- end
- # app/services/aura_service.rb
- class AuraService < BaseService
- def get_aura
- call_aura_remote_service(user_id)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement