Sha256: 62ee4ab95ecced55df025024fddee5bc630ab57eebeb2eced544417319975dc1
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module MongoDoc module Associations class DocumentProxy < ProxyBase attr_reader :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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongodoc-0.2.2 | lib/mongodoc/associations/document_proxy.rb |