Sha256: 917c9ff06c1dec875b86793a64e8c895bc96f1bd90129e35fd5689a5b99fa07f
Contents?: true
Size: 856 Bytes
Versions: 15
Compression:
Stored size: 856 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 def ensure_class(value) raise AssociationTypeMismatch, "expected instance of #{klass} but got #{value.class}" unless value.is_a?(klass) end protected def proxy_class self.class.parent::Proxy rescue Base::Proxy end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems