Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Polished Ruby Programming
  • Table Of Contents Toc
Polished Ruby Programming

Polished Ruby Programming - Second Edition

By : Jeremy Evans
close
close
Polished Ruby Programming

Polished Ruby Programming

By: Jeremy Evans

Overview of this book

Most successful Ruby applications become more difficult to maintain as the codebase grows in size. Polished Ruby Programming, 2nd Edition provides you with the skills and advice you need to design Ruby programs and libraries that are robust, performant, scalable, and maintainable. The book takes you through possible implementation approaches for many common programming situations, discusses the trade-offs inherent in each approach, and explains why you may sometimes choose to use different approaches. You'll start by learning fundamental Ruby programming principles, such as correctly using core classes, class and method design, variable usage, error handling, and code formatting. Then you’ll move on to higher-level topics such as library design, metaprogramming, domain-specific languages, and refactoring. Finally, you'll learn about the pros and cons of different approaches to concurrency, what you should consider when deciding whether to use static types in your Ruby code, and how best to optimize your Ruby code. The 2nd edition of Polished Ruby Programming has been updated to include relevant changes between Ruby 3.0 and 4.0. While most principles discussed in the book apply to all recent Ruby versions, some of the content in the book is specific to Ruby 4.0, the latest release at the time of publication.
Table of Contents (20 chapters)
close
close
18
Other Books You May Enjoy
19
Index

Final plugin system steps

When we added support for configuring the plugin system, we passed arguments from the plugin method to the before_load and after_load methods:

class Libry
  def self.plugin(mod, ...)
    # plugin loading code

    mod.before_load(self, ...) if mod.respond_to?(:before_load)

    # include/extend code

    mod.after_load(self, ...) if mod.respond_to?(:after_load)
  end
end

If either the before_load or after_load methods are supported by the plugin, this is fine. However, what if the plugin does not support those methods? What happens then is that users can provide any arguments to the plugin method, and the plugin method will just ignore them. That's bad for two reasons. First, the user probably passed arguments expecting them to do something, and they don't know the arguments are being ignored. Second, it means that if the plugin adds a before_load or after_load method in the future, the user's code could break.

One way to handle this is to have...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Polished Ruby Programming
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon