SlideShare a Scribd company logo
Font Test: Liberation Sans
I am monospace font
and kinda important, 32pt,
Ok?
LibreOffice
ife!!!
“orange”?
J
July 2017
September 2019
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
Nightmare on
else Street
def run_circuit(options)
steps.each do |step|
trace(options, step) if TRACING == true
step.call(options)
end
end
The Story of Trailblazer 3.0
is The Story of ifs.
2.1
if
Nick Sutterer
If is like vodka.
If you over-use it,
you get a headache.
Operative ifs vs. structural ifs
if email =~ /@/
else
end
if user.status == :suspended
&& action == :vote
raise “not allowed”
else
end
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
“
Pull
Requests,
yay!
+ if MYCOMPANY == true
+ img_path = “mycomp/imgs” + “hi.jpg”
+ img = image_tag(path)
+ section = content_for(:blog, img)
+ else
img_path = “/imgs” + “hi.jpg”
img = image_tag(path)
section = content_for(blog_name, img)
Milestone Codename
1.2.3 “Hello world”
2.0.0 “Hello world” 2.0.0
3.0.0 The Merb merge™
3.1.0 @wycats’s Revenge
4.0
5.0 Chatbot
6.0 Typo3 Drupal
X
rails$ wc -l respond_to?
129
if association.respond_to?(:to_ary)
Duck typing?
An object's suitability is determined by
the presence of certain methods [..],
rather than the type of the object itself.
– Wikipedia
LBYL
Look before you leap.
if
EAFP
Easier to ask for forgiveness than permission.
try/rescue
Compressive behavior of CNT in
polymer matrix with strong interfaces
obj.method_i_know #=> yay, works
obj.unknown_method #=> throw a
fucking
exception
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
STATIC
TYPING def celebrate(Attendee attendee)
celebrate(conference)
#=> compile-time error <3
if obj.is_a?(Conference)
raise “wrong argument!”
elsif obj.is_a?(Attendee)
# do it!
Method
Overloading
def celebrate(Attendee user)
user.drink_shot()
endattendee)
def celebrate(Conference conf)
conf.provide_free_beers_tonight()
endattendee)
# *cough*
if obj.is_a?(Conference)
handle_conf(obj)
elsif obj.is_a?(Attendee)
handle_attendee(obj)
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
Parametrization,
cause we can!
if MYCOMPANY == true
img_path = “mycomp/imgs” + “hi.jpg”
img = image_tag(path)
section = content_for(:blog, img)
else
img_path = “/imgs” + “hi.jpg”
img = image_tag(path)
section = content_for(blog_name, img)
def render_section(path, content_name)
img_path = path + “hi.jpg”
img = image_tag(path)
section = content_for(content_name, img)
if MYCOMPANY == true
render_section(“mycomp/imgs”, :blog)
else
render_section(“img”, blog_name)
Dispatching hashaction =
if type == :attendee
:register
elsif type == :speaker
:wake_up
elsif type == :matz
:make_tea
# ...
actions = {
attendee: :register,
speaker: :wake_up,
matz: :make_tea,
} # Extendable!
action = actions[type] # no if!
MyActions.send(action) # no if!
“Dispatching Hash”
Glass on white background | Artist: N. Sutterer | 2019 | Abstract painting on vinyl | € 3299,-
def order_beer_for(person) when person in [:ivan, :nick] do
# do something
end
class Attendee::Update < Trailblazer::Operation
step :find_attendee
step :validate
step :save
fail :alert_admin
step :notify_admin
end
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
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
trace(options) if TRACING == true
“Trust us”
...and now,
my dear friends,
let’s if together!
@apotonick
If - The Vodka of Ruby

More Related Content

Similar to If - The Vodka of Ruby

Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
Gianluca Padovani
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
Ruth Marvin
 
Ruby Intro {spection}
Ruby Intro {spection}Ruby Intro {spection}
Ruby Intro {spection}
Christian KAKESA
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
Matt Harrison
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
lachie
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test communityKerry Buckley
 
Forumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate AffairForumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate Affair
guest06ed72
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010
Plataformatec
 
The Final Programming Project
The Final Programming ProjectThe Final Programming Project
The Final Programming ProjectSage Jacobs
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsLeonardo Borges
 
ppt7
ppt7ppt7
ppt7
callroom
 
ppt2
ppt2ppt2
ppt2
callroom
 
name name2 n
name name2 nname name2 n
name name2 n
callroom
 
ppt9
ppt9ppt9
ppt9
callroom
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
amiable_indian
 
ppt18
ppt18ppt18
ppt18
callroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
callroom
 

Similar to If - The Vodka of Ruby (20)

Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
Mastering Python lesson 3a
Mastering Python lesson 3aMastering Python lesson 3a
Mastering Python lesson 3a
 
Ruby Intro {spection}
Ruby Intro {spection}Ruby Intro {spection}
Ruby Intro {spection}
 
Learn 90% of Python in 90 Minutes
Learn 90% of Python in 90 MinutesLearn 90% of Python in 90 Minutes
Learn 90% of Python in 90 Minutes
 
Beware sharp tools
Beware sharp toolsBeware sharp tools
Beware sharp tools
 
R Debugging
R DebuggingR Debugging
R Debugging
 
Blocks by Lachs Cox
Blocks by Lachs CoxBlocks by Lachs Cox
Blocks by Lachs Cox
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
 
Forumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate AffairForumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate Affair
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010
 
The Final Programming Project
The Final Programming ProjectThe Final Programming Project
The Final Programming Project
 
The Joy Of Ruby
The Joy Of RubyThe Joy Of Ruby
The Joy Of Ruby
 
Functional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event SystemsFunctional Reactive Programming / Compositional Event Systems
Functional Reactive Programming / Compositional Event Systems
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt9
ppt9ppt9
ppt9
 
Ruby for Perl Programmers
Ruby for Perl ProgrammersRuby for Perl Programmers
Ruby for Perl Programmers
 
ppt18
ppt18ppt18
ppt18
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 

Recently uploaded

20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

If - The Vodka of Ruby

  • 1. Font Test: Liberation Sans I am monospace font and kinda important, 32pt, Ok? LibreOffice ife!!! “orange”?
  • 2.
  • 4.
  • 5.
  • 6.
  • 7.
  • 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 “
  • 16. + if MYCOMPANY == true + img_path = “mycomp/imgs” + “hi.jpg” + img = image_tag(path) + section = content_for(:blog, img) + else img_path = “/imgs” + “hi.jpg” img = image_tag(path) section = content_for(blog_name, img)
  • 17. Milestone Codename 1.2.3 “Hello world” 2.0.0 “Hello world” 2.0.0 3.0.0 The Merb merge™ 3.1.0 @wycats’s Revenge 4.0 5.0 Chatbot 6.0 Typo3 Drupal X rails$ wc -l respond_to? 129 if association.respond_to?(:to_ary)
  • 18. Duck typing? An object's suitability is determined by the presence of certain methods [..], rather than the type of the object itself. – Wikipedia
  • 19. LBYL Look before you leap. if EAFP Easier to ask for forgiveness than permission. try/rescue
  • 20. Compressive behavior of CNT in polymer matrix with strong interfaces
  • 21. obj.method_i_know #=> yay, works obj.unknown_method #=> throw a fucking exception
  • 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
  • 23. STATIC TYPING def celebrate(Attendee attendee) celebrate(conference) #=> compile-time error <3 if obj.is_a?(Conference) raise “wrong argument!” elsif obj.is_a?(Attendee) # do it!
  • 24. Method Overloading def celebrate(Attendee user) user.drink_shot() endattendee) def celebrate(Conference conf) conf.provide_free_beers_tonight() endattendee) # *cough* if obj.is_a?(Conference) handle_conf(obj) elsif obj.is_a?(Attendee) handle_attendee(obj)
  • 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
  • 26. Parametrization, cause we can! if MYCOMPANY == true img_path = “mycomp/imgs” + “hi.jpg” img = image_tag(path) section = content_for(:blog, img) else img_path = “/imgs” + “hi.jpg” img = image_tag(path) section = content_for(blog_name, img) def render_section(path, content_name) img_path = path + “hi.jpg” img = image_tag(path) section = content_for(content_name, img) if MYCOMPANY == true render_section(“mycomp/imgs”, :blog) else render_section(“img”, blog_name)
  • 27. Dispatching hashaction = if type == :attendee :register elsif type == :speaker :wake_up elsif type == :matz :make_tea # ... actions = { attendee: :register, speaker: :wake_up, matz: :make_tea, } # Extendable! action = actions[type] # no if! MyActions.send(action) # no if! “Dispatching Hash”
  • 28. Glass on white background | Artist: N. Sutterer | 2019 | Abstract painting on vinyl | € 3299,-
  • 29. def order_beer_for(person) when person in [:ivan, :nick] do # do something end
  • 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
  • 33.
  • 35.
  • 36.
  • 38. ...and now, my dear friends, let’s if together! @apotonick