lib/mongoid/relations/one.rb in mongoid-2.0.0.rc.4 vs lib/mongoid/relations/one.rb in mongoid-2.0.0.rc.5

- old
+ new

@@ -4,9 +4,27 @@ # This is the superclass for one to one relations and defines the common # behaviour or those proxies. class One < Proxy + # Will load the target into an array if the target had not already been + # loaded. + # + # @example Load the relation into memory. + # relation.load! + # + # @return [ One ] The relation. + # + # @since 2.0.0.rc.5 + def load!(options = {}) + tap do |relation| + unless relation.loaded? + relation.bind(options) + relation.loaded = true + end + end + end + # Substitutes the supplied target documents for the existing document # in the relation. # # @example Substitute the new document. # person.name.substitute(new_name)