This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def location_in_hierarchy(object, method) | |
history = [] | |
current = object.class | |
history << current | |
while (current.superclass!=nil) | |
history << current.superclass | |
current = current.superclass | |
end | |
history = history.reverse | |
history.find do |ob| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What is method_missing ? | |
When we send a message to an object, it first method it finds on its method lookup path with the same name as message. If it fails to find any method like this then it will raise NoMethodError exception. | |
method_missing is a known tool in the Ruby meta-programming toolbox. It’s a callback method that gets called when an object tries to call a method that is missing. An example of this is dynamic finders in ActiveRecord. Let's say Member has an email attribute, you can do Member.find_by_email('[email protected]') and the interesting fact is that User and ActiveRecord::Base have not defined it. | |
example: | |
class MyClass |