ack

that does it :)

13 scenarios (13 passed)
61 steps (61 passed)
0m0.426s


On 17/01/12 18:15, mfoj...@redhat.com wrote:
> From: Michal Fojtik <mfoj...@redhat.com>
> 
> 
> Signed-off-by: Michal fojtik <mfoj...@redhat.com>
> ---
>  server/lib/deltacloud/core_ext/proc.rb |   20 ++++++++++++--------
>  1 files changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/server/lib/deltacloud/core_ext/proc.rb 
> b/server/lib/deltacloud/core_ext/proc.rb
> index 3c443ff..1917123 100644
> --- a/server/lib/deltacloud/core_ext/proc.rb
> +++ b/server/lib/deltacloud/core_ext/proc.rb
> @@ -13,15 +13,19 @@
>  # License for the specific language governing permissions and limitations
>  # under the License.
>  
> -# Original code copied from: 
> http://www.mattsears.com/articles/2011/11/27/ruby-blocks-as-dynamic-callbacks
> -# Copyright 2011 Matt Sears.
> +# Original code copied from https://gist.github.com/1417762
> +# Copyright 2011 Emmanuel Oga.
> +
>  class Proc
> +
> +  Callback = Struct.new(:called, :args) do
> +    def method_missing(name, *)
> +      name == :"#{called}?" || (name == called && block_given? && 
> yield(*args))
> +    end
> +  end
> +
>    def callback(callable, *args)
> -    self === Class.new do
> -      method_name = callable.to_sym
> -      define_method(method_name) { |&block| block.nil? ? true : 
> block.call(*args) }
> -      define_method("#{method_name}?") { true }
> -      def method_missing(method_name, *args, &block) false; end
> -    end.new
> +    call Callback.new(callable, *args)
>    end
> +
>  end

Reply via email to