Video Review: Object Models
Last updated
Last updated
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
24 lines (17 sloc) 1.35 KB
This video gives an overview of object models and how to make our classes more powerful.
Create a class and add reader and writer methods
Define class methods with an explicit self
receiver
Capture new instances of self
in the initialize
method
Use a class variable or constant to hold the instances of the class
Explain why we avoid using the return
keyword from within a loop
Define a find_by_location
method to find a particular instance of a class
Abstract the logic of the find_by_location
method to a detect
enumerable method
Define a class method find_all_by_location
to find all instances with that location using the select
enumerable method
Define a custom constructor method to create instances from attributes scraped from a website
This video also covers many of the above topics in the main lesson video. Feel free to use this as another refresher on object models.
<iframe width="100%" height="720" src="" frameborder="0" allowfullscreen></iframe>
View on Learn.co and start learning to code for free.