• ProductFirmware • ProductModel • ProductState • ProductType • ProductCreator • ProductFinder Klasy: • Quality • QualityComment • QualityHasSerialNumber • QualityType Które klasy są modelami, a które są klasami Service Object ?
• ProductFirmware • ProductModel • ProductState • ProductType • ProductCreator • ProductFinder Klasy: • Quality • QualityComment • QualityHasSerialNumber • QualityType Które klasy są modelami, a które są klasami Service Object ?
User.where(email: params[:email]).first if UserAuthenticator.new(user).authenticate(params[:password]) self.current_user = user redirect_to dashboard_path else flash[:alert] = "Login failed." render "new" end end end
User.where(email: params[:email]).first if UserAuthenticator.new(user).authenticate(params[:password]) self.current_user = user redirect_to dashboard_path else flash[:alert] = "Login failed." render "new" end end end
create_succeeded(user, message) self.current_user = user redirect_to dashboard_path end def create_failed(message) flash[:alert] = message render "new" end end October CincyRb - Jim Weirich on Decoupling from Rails
{ self.current_user = user redirect_to dashboard_path }, failure: ->(message) { flash[:alert] = message render "new" }) end end Interactor October CincyRb - Jim Weirich on Decoupling from Rails
FormObject, View, ViewModel • Presenter - Jay Fields (http:/ /blog.jayfields.com/2007 /03/ rails-presenter-pattern.html) „The Presenter pattern addresses bloated controllers and views containing logic in concert by creating a class representation of the state of the view. An architecture that uses the Presenter pattern provides view specific data as attributes of an instance of the Presenter. The Presenter's state is an aggregation of model and user entered data.”
problematyczne działanie konstrukcja reguł w ability.rb uzależniona od używanego ORMa (ActiveRecord, DataMapper, Mongoid) Helpery Policy Object niezależny od ORMa używany tylko do pojedynczych obiektów a nie do kolekcji