diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-17 02:48:41 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-03-17 02:48:41 +0000 |
| commit | ba23a5ac276e59fdda8186750c6d0fd2cfecdeac (patch) | |
| tree | 1e14b25ade74ea52d8da2788ede9b12b507867e8 /test/lib/spec/runner/extensions/object.rb | |
| parent | 8ea6adaeb1e3d0aa6348c2a2c3a385d185372d06 (diff) | |
Adding spec libs, so we can use them some day
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2283 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'test/lib/spec/runner/extensions/object.rb')
| -rw-r--r-- | test/lib/spec/runner/extensions/object.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/lib/spec/runner/extensions/object.rb b/test/lib/spec/runner/extensions/object.rb new file mode 100644 index 000000000..49745352f --- /dev/null +++ b/test/lib/spec/runner/extensions/object.rb @@ -0,0 +1,32 @@ +# The following copyright applies to Object#copy_instance_variables_from, +# which we borrowed from active_support. +# +# Copyright (c) 2004 David Heinemeier Hansson +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +class Object + # From active_support + def copy_instance_variables_from(object, exclude = []) # :nodoc: + exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables + + instance_variables = object.instance_variables - exclude.map { |name| name.to_s } + instance_variables.each { |name| instance_variable_set(name, object.instance_variable_get(name)) } + end +end |
