Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2011 06:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/875697 to your computer and use it in GitHub Desktop.
Save anonymous/875697 to your computer and use it in GitHub Desktop.
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