deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: [PATCH core 1/3] Make sure the exception DSL does not override
Date Tue, 25 Sep 2012 17:12:36 GMT
On Sat, 2012-09-22 at 00:33 +0200, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mfojtik@redhat.com>
> 
> This patch fixed the case when the exception DSL is
> used more than once (typically on driver switching).
> In that case the new exceptions will override the exceptions
> from the previous driver.
> 
> Signed-off-by: Michal fojtik <mfojtik@redhat.com>

ACK; one nit:

> diff --git a/server/lib/deltacloud/drivers/exceptions.rb b/server/lib/deltacloud/drivers/exceptions.rb
> index 5e679a5..1a635ce 100644
> --- a/server/lib/deltacloud/drivers/exceptions.rb
> +++ b/server/lib/deltacloud/drivers/exceptions.rb
> @@ -171,9 +171,15 @@ module Deltacloud
>        end
>      end
>  
> -    def self.exceptions(&block)
> -      @definitions = Exceptions.new(&block).exception_definitions if block_given?
> -      @definitions
> +    module DSL
> +      def exceptions(&block)
> +        @definitions = Exceptions.new(&block).exception_definitions if block_given?
> +        @definitions
> +      end
> +    end

You should initialize @definitions ||= [] to make sure that drivers
without exception definitions don't cause an error in safely trying to
call each on nil.



Mime
View raw message