Stateless Code | Codecast: Create a RubyGem 68: Implement the First Magic Method @StatelessCode | Uploaded October 2021 | Updated October 2024, 2 hours ago.
This is the 68th video in the NerdDice create a RubyGem series. In this video Mike writes the specs for the roll_dNN pattern and implements it so that the following requirements are met:
* roll_dNN works and rolls one die
* Method is defined on the object after magic method is called
* Keyword arguments are correctly passed to the method when delegated
* :respond_to_missing? is defined and overwritten properly
This video covers:
00:00:12 Introduction
00:01:25 Create folder and file for spec
00:02:40 Write describe and it statements
00:04:07 Write the specs for the method
00:05:48 Test out specs and make a couple of fixes
00:08:12 Start implementing method_missing override
00:11:20 Use Rubular to write and test regular expression pattern
00:14:02 Use private methods to parse the method name, use define_method and call NerdDice.roll_dice
00:18:09 Troubleshoot failing specs (specs using wrong pattern)
00:21:34 Troubleshoot issue with spec that observes method_missing (forgot to add and_call_original)
00:31:27 Review and fix RuboCop violations except for :respond_to_missing?
00:37:58 Implement specs and override for :respond_to_missing?
00:42:55 Commit and push code. Update backlog.
This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
This is the 68th video in the NerdDice create a RubyGem series. In this video Mike writes the specs for the roll_dNN pattern and implements it so that the following requirements are met:
* roll_dNN works and rolls one die
* Method is defined on the object after magic method is called
* Keyword arguments are correctly passed to the method when delegated
* :respond_to_missing? is defined and overwritten properly
This video covers:
00:00:12 Introduction
00:01:25 Create folder and file for spec
00:02:40 Write describe and it statements
00:04:07 Write the specs for the method
00:05:48 Test out specs and make a couple of fixes
00:08:12 Start implementing method_missing override
00:11:20 Use Rubular to write and test regular expression pattern
00:14:02 Use private methods to parse the method name, use define_method and call NerdDice.roll_dice
00:18:09 Troubleshoot failing specs (specs using wrong pattern)
00:21:34 Troubleshoot issue with spec that observes method_missing (forgot to add and_call_original)
00:31:27 Review and fix RuboCop violations except for :respond_to_missing?
00:37:58 Implement specs and override for :respond_to_missing?
00:42:55 Commit and push code. Update backlog.
This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.