Introduce Expression Builder

You want to interact with a public interface in a more fluent manner and not muddy the interface of an existing object.

Introduce an Expression Builder and create an interface specific to your application.

image/svg+xml Person save Post Gateway savesubject=attributes=to=authenticate= def save PostGateway.save do |persist| persist.subject = self persist.attributes = {:first_name, :last_name, :ssn] persist.authenticate = true persist.to = 'http://www.example.com/person" endend Post Gateway savesubject=attributes=to=authenticate= Gateway Expression Builder postwith_authenticationto Person httpsave return GatewayExpressionBuilder.new(self) def save http.post(:assigned_to, :serial_number). with_authentication. to('http://www.example.com/issued_laptop")end