Sha256: 8fd3d1bbe8c765a8a4bf8a155b8dece35e790c53c1c29b341d98eb1900270016
Contents?: true
Size: 868 Bytes
Versions: 25
Compression:
Stored size: 868 Bytes
Contents
require 'active_support/core_ext/module/introspection' module MongoModel module Associations module Base class Association attr_reader :definition, :instance delegate :name, :klass, :polymorphic?, :to => :definition def initialize(definition, instance) @definition, @instance = definition, instance end def proxy @proxy ||= proxy_class.new(self) end def replace(obj) proxy.target = obj proxy end protected def ensure_class(value) raise AssociationTypeMismatch, "expected instance of #{klass} but got #{value.class}" unless value.is_a?(klass) end private def proxy_class self.class.parent::Proxy rescue Base::Proxy end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems