lib/cloudstack_client/client.rb in cloudstack_client-1.0.2 vs lib/cloudstack_client/client.rb in cloudstack_client-1.0.3
- old
+ new
@@ -15,27 +15,30 @@
end
def define_api_methods
@api = Api.new(@options)
@api.commands.each do |name, command|
- method_name = camel_case_to_underscore(command.name).to_sym
+ method_name = camel_case_to_underscore(command["name"]).to_sym
define_singleton_method(method_name) do |args = {}, options = {}|
- params = {"command" => command.name}
+ params = { "command" => command["name"] }
args.each do |k, v|
- k = @api.normalize_key(k)
- if v != nil && @api.command_supports_param?(command.name, k)
+ k = k.to_s.gsub("_", "")
+ if v && @api.command_supports_param?(command["name"], k)
params[k] = v
end
end
- unless @api.all_required_params?(command.name, params)
- raise ParameterError, @api.missing_params_msg(command.name)
+ unless @api.all_required_params?(command["name"], params)
+ raise ParameterError, @api.missing_params_msg(command["name"])
end
- sync = command.isasync == false || options[:sync]
- sync ? send_request(params) : send_async_request(params)
+ if command["isasync"] == false || options[:sync]
+ send_request(params)
+ else
+ send_async_request(params)
+ end
end
end
end
end # class