Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Control methods like a pro: A guide to Ruby's awesomeness, a.k.a. metaprogramming by Masafumi Okura Do you know that methods are objects in Ruby? We can manipulate method objects just like other object, meaning that we can store them in variables, get information from them and wrap them in other objects like Proc. In this talk, I'll show a real-world example of manipulating methods. I'll cover from the basic such as listing available methods and getting a method object to the difference between Method and UnboundMethod and redefining methods with original method object.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this talk titled 'Control methods like a pro: A guide to Ruby's awesomeness,' Masafumi Okura explores the advanced features of methods in Ruby, especially focusing on metaprogramming. Okura begins by highlighting the unique aspect of methods in Ruby: they are objects, which allows for dynamic manipulation such as storing them in variables and wrapping them in other objects like Proc. Key points discussed in the video include: - **Understanding Methods**: Okura emphasizes the need for Ruby programmers to deepen their understanding of methods beyond basic usage. He introduces the idea of having conventions over method invocations, like how testing frameworks detect test methods automatically. - **Listing Methods**: The talk explains Ruby's built-in capabilities to list available methods for objects, using methods like `methods`, `private_methods`, and `singleton_methods`. Okura distinguishes between the return types of these methods, noting that they return method names as symbols, not method objects directly. - **Method Objects**: The concept of method objects in Ruby is elaborated upon. Okura distinguishes between `Method` and `UnboundMethod`, explaining how both work and their respective use cases. Method objects can be stored in variables and invoked later, while unbound methods require binding to an object before invocation. - **Defining and Redefining Methods**: The presentation showcases various dynamic methods of defining methods in Ruby, emphasizing the use of `define_method` for creating methods at runtime. Okura also discusses the processes of undefined and removing methods, illustrating the dynamic nature of Rails application methods. - **Real-World Application**: Throughout the talk, Okura presents a real-world example involving a logic class that collects validation methods, emphasizing how the framework allows for clean logic separation without sacrificing performance. He discusses the `tiny hooks` library he created, which manages hooks efficiently. - **Conclusions**: The speaker encourages Ruby developers to embrace metaprogramming, summarizing that manipulating methods does not break Ruby but instead enhances its capabilities. In conclusion, Okura urges the audience to explore methods in Ruby further and to utilize tools like `tiny hooks` to improve performance and maintainability in their coding practices. The video serves as a comprehensive guide for Ruby developers looking to leverage the power of methods and reevaluate their understanding of language features.
Suggest modifications
Cancel