Sunday, December 11, 2011

[Rails] Re: This modules thing somehow really does not work for me, please help.

On Dec 11, 6:10 pm, Peter Vandenabeele <pe...@vandenabeele.com> wrote:

> So, my experiments seem to suggest that in both cases
> that I tried, there is an explicit order where all intermediate
> modules are loaded in turn (with load_missing_constants),
> even if only the deepest module would be strictly required to
> evaluate X::Y::Z
>
> Could you show an example of where the problem you described
> occurs. Or maybe this behavior has changed recently?

Yeah I mixed things up a bit there as well as slightly mis-
remembering. if you do things as rails expects, and rely entirely on
the const_missing hooks then either way works. but if you deviate from
that then things are different.

For example if z.rb is

module X
module Y
module Z
end
end
end

and you do require_dependency 'x/y/z' then x/y.rb won't be loaded

but if you do

module X::Y::Z
end

then it will.

I guess the point I was trying to make was that if ruby ends up
reading z.rb then using module X::Y::Z guarantees that x.rb and x/y.rb
will be read, but the other form doesn't, although the usual scenarios
would mean that x.rb and x/y.rb would have been read earlier on
anyway.

Fred


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate