mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
use terrible hacks to make this work when rails tries to marshal
This commit is contained in:
@@ -51,14 +51,16 @@ module ActiveRecord
|
||||
instance_methods.each { |m| undef_method m unless m.to_s =~ /^(?:nil\?|send|object_id)$|^__|^respond_to_missing|proxy_/ }
|
||||
|
||||
def self.new(owner, reflection)
|
||||
klass = if reflection.options[:extend]
|
||||
reflection.instance_variable_get(:@_extend_class) ||
|
||||
reflection.instance_variable_set(:@_extend_class, Class.new(self) do
|
||||
include *reflection.options[:extend]
|
||||
end)
|
||||
else
|
||||
self
|
||||
end
|
||||
klass =
|
||||
reflection.cached_extend_class ||=
|
||||
if reflection.options[:extend]
|
||||
const_name = "AR_CACHED_EXTEND_CLASS_#{reflection.name}_#{reflection.options[:extend].join("_")}"
|
||||
reflection.active_record.const_set(const_name, Class.new(self) do
|
||||
include *reflection.options[:extend]
|
||||
end)
|
||||
else
|
||||
self
|
||||
end
|
||||
|
||||
proxy = klass.allocate
|
||||
proxy.send(:initialize, owner, reflection)
|
||||
|
||||
@@ -77,6 +77,7 @@ module ActiveRecord
|
||||
# those classes. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.
|
||||
class MacroReflection
|
||||
attr_reader :active_record
|
||||
attr_accessor :cached_extend_class
|
||||
|
||||
def initialize(macro, name, options, active_record)
|
||||
@macro, @name, @options, @active_record = macro, name, options, active_record
|
||||
|
||||
Reference in New Issue
Block a user