Created — forked from nusco/before_method_missing_1.rb

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View before_method_missing_1.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class DoNotDisturb
include DeskTasks
 
def check_lunch_break
hour = Time.now.hour
raise "Out for lunch" if hour >= 12 && hour < 14
end
def emergency
"emergency() called"
end
end
 
# At 12:30...
DoNotDisturb.new.emergency # => "emergency() called"
DoNotDisturb.new.flights # ~> -:32:in `check_lunch_break': Out for lunch (RuntimeError)
View before_method_missing_1.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
module DeskTasks
def check_lunch_break
true # or a no-op, or whatever is useful here
end
 
def emergency
# Call emergency...
check_lunch_break
"emergency() called"
end
def flights
# Provide flight information...
check_lunch_break
"flights() called"
end
def local_transports
# Return a metro map...
check_lunch_break
"local_transports() called"
end
def hotels
# Find a suitable hotel...
check_lunch_break
"hotels() called"
end
# ...even more methods
end
Owner

No description provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.