From: Michal Fojtik <[email protected]> * ActionHandler now advertise mappings using 'mappings' method * deltacloud_method_params now survive repetetive calls
Signed-off-by: Michal fojtik <[email protected]> --- server/lib/ec2/query_parser.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/server/lib/ec2/query_parser.rb b/server/lib/ec2/query_parser.rb index 8050119..2098d24 100644 --- a/server/lib/ec2/query_parser.rb +++ b/server/lib/ec2/query_parser.rb @@ -31,6 +31,10 @@ module Deltacloud::EC2 :terminate_instances => { :method => :destroy_instance, :params => { 'InstanceId.1' => :id }}, } + def self.mappings + MAPPINGS + end + attr_reader :action def initialize(action) @@ -38,12 +42,13 @@ module Deltacloud::EC2 end def deltacloud_method - MAPPINGS[action.action][:method] + self.class.mappings[action.action][:method] end def deltacloud_method_params - MAPPINGS[action.action][:params].inject({}) do |result, p| - result[p.last] = action.parameters.delete(p.first) + parameters = action.parameters.dup + self.class.mappings[action.action][:params].inject({}) do |result, p| + result[p.last] = parameters.delete(p.first) result.delete_if { |k,v| v.nil? } end end @@ -137,7 +142,7 @@ module Deltacloud::EC2 end def valid_actions - ActionHandler::MAPPINGS.keys + ActionHandler::mappings.keys end def valid_action? -- 1.7.10.2
