8. TRB in 90 sec.TRB in 90 sec.TRB in 90 sec.
1.0
class CommentsController
def update
run Comment::Update
end
2.0
class Comment::Update < …::Operation
step :find_model
step :validate
step :save
fail :alert_admin
step :notify_admin
nd
2.1
9. Nightmare on
else Street
def run_circuit(options)
steps.each do |step|
trace(options, step) if TRACING == true
step.call(options)
end
end
10. The Story of Trailblazer 3.0
is The Story of ifs.
2.1
12. If is like vodka.
If you over-use it,
you get a headache.
13. Operative ifs vs. structural ifs
if email =~ /@/
else
end
if user.status == :suspended
&& action == :vote
raise “not allowed”
else
end
14. Business processes will always be
complex, son. There ain’t no way
to, like, simplify those.
But there are good and, eh, bad
tools to deal with… yeah, right,
complexity!
– Donald Trump, 1644
“
22. class Developer
implements Attendee
def drink_shot()
end
end
class HRManager
implements Attendee
def drink_shot()
end
end
def celebrate(attendee)
attendee.drink_shot()
end
def celebrate(Attendee attendee)
attendee.drink_shot()
end
25. Functional API
class Attendee
def attend(conference)
def celebrate
raise if @is_attending.nil?
class Attendee
public def live(conference)
attend(conference)
celebrate
end
OOP
30. class Attendee::Update < Trailblazer::Operation
step :find_attendee
step :validate
step :save
fail :alert_admin
step :notify_admin
end
31. class Attendee::Update < Trailblazer::Operation
step :find_attendee
step :validate
step :save
fail :alert_admin
step :notify_admin
end
def process(…)
if find_attendee(…)
if validate(…)
if save(…)
if notify_admin(…)
else
alert_admin(…)
end
else
alert_admin(…)
end
else
alert_admin(…)
end
end
32. class Attendee::Update < Trailblazer::Operation
step :find_attendee
step :validate
step :save
fail :alert_admin
step :notify_admin
end
activity Attendee::Update
step :find_attendee
step :validate
step :save
fail :alert_admin
step :notify_admin
end