Class/Module Index [+]

Quicksearch

Mongoid::Extensions::Object::Reflections

This module contains reflection convenience methods.

Public Instance Methods

ivar(name) click to toggle source

Get the value for an instance variable or nil if it doesn’t exist.

@example Get the value for an instance var.

document.ivar("person")

@param [ String ] name The name of the variable.

@return [ Object, nil ] The value or nil.

@since 2.0.0.rc.1

# File lib/mongoid/extensions/object/reflections.rb, line 19
def ivar(name)
  if instance_variable_defined?("@#{name}")
    return instance_variable_get("@#{name}")
  else
    false
  end
end
remove_ivar(name) click to toggle source

Remove the instance variable for the provided name.

@example Remove the instance variable

document.remove_ivar("person")

@param [ String ] name The name of the variable.

@return [ true, false ] If the variable was defined.

@since 2.1.0

# File lib/mongoid/extensions/object/reflections.rb, line 37
def remove_ivar(name)
  if instance_variable_defined?("@#{name}")
    return remove_instance_variable("@#{name}")
  else
    false
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.