lib/evil/client/operation/request.rb in evil-client-0.2.3 vs lib/evil/client/operation/request.rb in evil-client-0.3.0
- old
+ new
@@ -11,12 +11,12 @@
# @return [Hash]
#
def build(options)
{
format: schema[:format],
- http_method: http_method,
- path: path.call(options),
+ http_method: extract(:method),
+ path: extract(:path).call(options),
security: schema[:security]&.call(options),
files: schema[:files]&.call(options),
query: schema[:query]&.new(options).to_h,
body: schema[:body]&.new(options).to_h,
headers: schema[:headers]&.new(options).to_h
@@ -27,16 +27,11 @@
def key
@key ||= schema[:key]
end
- def http_method
- return schema[:method] if schema[:method]
- fail NotImplementedError.new "No method defined for operation '#{key}'"
- end
-
- def path
- return schema[:path] if schema[:path]
- fail NotImplementedError.new "Path not defined for operation '#{key}'"
+ def extract(property)
+ return schema[property] if schema[property]
+ raise NotImplementedError, "No #{property} defined for operation '#{key}'"
end
end
end