This file contains 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
class CarPart | |
# does the method name end in _price ? | |
def ghost_method_condition(name) | |
!!name.to_s[/_price$/] | |
end | |
# rewrite method missing if the method matches ghost_method_condition | |
def method_missing(name, *args, &block) | |
super unless ghost_method_condition(name) |