Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
class InformationDesk
include DeskTasks
end
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)
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
@ghost

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Oct 7, 2010

No description provided.

Owner

ghost commented Oct 7, 2010

No description provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment