Sha256: e58c4128212414222ffae3e29dcbf98cd1a3ac652705ecf2b8c0c64dda2ad95f

Contents?: true

Size: 718 Bytes

Versions: 21

Compression:

Stored size: 718 Bytes

Contents

class Object
  # Available in 1.8.6 and later.
  unless respond_to?(:instance_variable_defined?)
    def instance_variable_defined?(variable)
      instance_variables.include?(variable.to_s)
    end
  end

  def instance_values #:nodoc:
    instance_variables.inject({}) do |values, name|
      values[name.to_s[1..-1]] = instance_variable_get(name)
      values
    end
  end

  def copy_instance_variables_from(object, exclude = []) #:nodoc:
    exclude += object.protected_instance_variables if object.respond_to? :protected_instance_variables

    vars = object.instance_variables.map(&:to_s) - exclude.map(&:to_s)
    vars.each { |name| instance_variable_set(name, object.instance_variable_get(name)) }
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activesupport-2.0.1 lib/active_support/core_ext/object/instance_variables.rb
activesupport-2.0.0 lib/active_support/core_ext/object/instance_variables.rb
activesupport-2.0.2 lib/active_support/core_ext/object/instance_variables.rb
activesupport-2.0.5 lib/active_support/core_ext/object/instance_variables.rb
activesupport-2.0.4 lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.157 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb