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
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/object/instance_variables.rb