Create a gist now

Instantly share code, notes, and snippets.

anonymous /service.rb
Created Mar 18, 2011

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