Skip to content

Instantly share code, notes, and snippets.

@nathan-appere
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathan-appere/dfdd4fa5fa81f080c70f to your computer and use it in GitHub Desktop.
Save nathan-appere/dfdd4fa5fa81f080c70f to your computer and use it in GitHub Desktop.
Enforce interface manually because sometimes ruby lets you down.
class Coupon
class << self
def enforce_interface!
methods = self.instance_methods(false)
[:m].each do |method_name|
unless methods.include? method_name
raise "#{method_name} should be implemented"
end
end
end
end
end
class SharingCoupon < Coupon
def m
end
enforce_interface!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment