lib/nationbuilder/client.rb in nationbuilder-rb-0.0.2 vs lib/nationbuilder/client.rb in nationbuilder-rb-0.0.3
- old
+ new
@@ -12,11 +12,15 @@
def parsed_endpoints
NationBuilder::SpecParser
.parse(File.join(File.dirname(__FILE__), 'api_spec.json'))
end
+ class InvalidEndpoint < ArgumentError; end
+
def [](endpoint)
- @name_to_endpoint[endpoint]
+ e = @name_to_endpoint[endpoint]
+ raise InvalidEndpoint.new(endpoint) if e.nil?
+ e
end
def endpoints
@name_to_endpoint.keys
end