ActionView module declared several times

11 views
Skip to first unread message

John Merlino

unread,
Sep 3, 2012, 2:08:42 PM9/3/12
to Ruby on Rails: Talk
The ActionView module is declared several times in the Rails source:

rails/actionpack/lib/action_view/base.rb,rails/actionpack/lib/
action_view/buffers.rb,rails/actionpack/lib/action_view/digestor.rb,
rails/actionpack/lib/action_view/helpers/asset_tag_helpers/
asset_paths.rb, and the list goes on and on.

How is it able to be declared like this in multiple files without the
previous definition of it being overwritten?

Colin Law

unread,
Sep 3, 2012, 4:04:23 PM9/3/12
to rubyonra...@googlegroups.com
It is a basic feature of Ruby that you can re-open a class definition
and add or redefine methods.

Colin

Иван Бишевац

unread,
Sep 3, 2012, 6:22:22 PM9/3/12
to rubyonra...@googlegroups.com
2012/9/3 John Merlino <stoi...@aol.com>

--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


It's kind of "metaprogramming—creating code at runtime that defines new methods. In fact, in a sense all Ruby programming is metaprogramming, since even a class definition is not a declaration as it is in Java but actually code that is executed at runtime. Given that this is true, you might wonder whether you can modify a class at runtime. In fact you can, by adding or changing instance methods or class methods, even for Ruby’s built-in classes".

John Merlino

unread,
Sep 3, 2012, 9:31:06 PM9/3/12
to Ruby on Rails: Talk
Yes, it is a basic feature of ruby that you can reopen a class
definition. I forgot about that.

On Sep 3, 4:05 pm, Colin Law <clan...@googlemail.com> wrote:

uma mahesh varma Seeram

unread,
Sep 4, 2012, 1:02:16 AM9/4/12
to rubyonra...@googlegroups.com
The metaprogramming nature of ruby is the most advantage feature of ruby. 

Thank You,
Uma Mahesh.
Reply all
Reply to author
Forward
0 new messages