Sha256: e20d8e3f9b20bbc5ef8a6d184a02e0d7adfc2e9e993f4d0ca2ceeaff79002a46
Contents?: true
Size: 1.13 KB
Versions: 7
Compression:
Stored size: 1.13 KB
Contents
module MongoDoc module Associations class DocumentProxy include ProxyBase attr_reader :document delegate :to_bson, :id, :to => :document def _root=(root) @_root = root document._root = root if is_document?(document) end def ==(other) if self.class === other document == other.document else document == other end end def build(attrs) item = assoc_class.new(attrs) self.document = item end def document=(doc) attach(doc) @document = doc end def valid? if is_document?(document) document.valid? else true end end private def method_missing(method, *args) unless document.respond_to?(method) raise NoMethodError, "undefined method `#{method.to_s}' for proxied \"#{document}\":#{document.class.to_s}" end if block_given? document.send(method, *args) { |*block_args| yield(*block_args) } else document.send(method, *args) end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems