Professional Documents
Culture Documents
METHOD_MISSING
Called when Ruby cant nd a method
class Tweet
def method_missing(method_name, *args)
puts "You tried to call #{method_name} with these arguments: #{args}"
end
end
class Tweet
def method_missing(method_name, *args)
logger.warn "You tried to call #{method_name} with these arguments: #{args}"
super
end
end write to our log
Tweet.new.submit(1, "Here's a tweet.")
def avatar
@user.avatar
end
end
works bec a us e w e
h od _ mi s s i n g lies!!!
defined met
tweet.method(:hash_ruby)
tweet = Tweet.new
tweet.method(:hash_ruby)
tweet.hash_codeschool
tweet.hash_codeschool