Sha256: 7ca4167f3cab39d9acfe619804a517dc362d2613c3ba646ac073fe525e7263c4

Contents?: true

Size: 443 Bytes

Versions: 19

Compression:

Stored size: 443 Bytes

Contents

module MongoMapper
  module Associations
    class BelongsToProxy < Proxy
      def replace(doc)
        if doc
          doc.save if doc.new?
          id = doc.id
        end
        
        owner[reflection.foreign_key] = id
        reset
      end

      protected
        def find_target
          return nil if owner[reflection.foreign_key].nil?
          klass.first(:id => owner[reflection.foreign_key])
        end
    end
  end
end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
mrkurt-mongo_mapper-0.6.11 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2010.1.6 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2010.1.5 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2010.1.4 lib/mongo_mapper/associations/belongs_to_proxy.rb
tpitale-mongo_mapper-0.6.10 lib/mongo_mapper/associations/belongs_to_proxy.rb
mrkurt-mongo_mapper-0.6.10 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-0.6.10 lib/mongo_mapper/associations/belongs_to_proxy.rb
mrkurt-mongo_mapper-0.6.9 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-0.6.9 lib/mongo_mapper/associations/belongs_to_proxy.rb
mrkurt-mongo_mapper-0.6.8 lib/mongo_mapper/associations/belongs_to_proxy.rb
tpitale-mongo_mapper-0.6.9 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.30 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.29 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.23 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.22 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.16 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-0.6.8 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-unstable-2009.12.14 lib/mongo_mapper/associations/belongs_to_proxy.rb
mongo_mapper-0.6.7 lib/mongo_mapper/associations/belongs_to_proxy.rb