Interesting.

The problem is that the const_missing in Delegator issues
::Object.const_get by hand. Essentially this is the situation (modulus I
still need coffee :):

  class Object
    def self.const_missing(cname)
      1
    end
  end

  class C < BasicObject
    def self.const_missing(cname)
      ::Object.const_get(cname)
    end
  end

  C::A # => 1

The problem there is that Delegator effectively throws the namespace by
calling const_get on Object.

To have the constant autoloaded MyThing.const_missing should be invoked
instead for Rails to know it should look into that namespace as one of
possible candidates (it can because self.name returns "MyThing").

In general, to play by the rules const_missing in a class should call super
if if is not able to find the constant, but Delegate cannot assume a lot
since it inherits from BasicObject. On the other hand I don't quite see the
point in that implementation, doing Object.const_get sounds quite arbitrary
to me at first sight, doesn't make a lot of sense to me.

I don't have a workaround to propose right now, let me think about it, but
that's more or less the situation.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to