Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2011 06:32
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
class Service
class << self
def meta_def(name, &block)
define_singleton_method(name, &block)
end
def responses(hash)
hash.each do |method_name, result|
meta_def(method_name) do
result
end
end
end
end
responses :success => 20, :unreachable => 23
end
Service.success # => 20
Service.unreachable # => 23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment