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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 3 September 2012 19:08, John Merlino <stoicism1-YDxpq3io04c@public.gmane.org> wrote:> 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?It is a basic feature of Ruby that you can re-open a class definition and add or redefine methods. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
2012/9/3 John Merlino <stoicism1-YDxpq3io04c@public.gmane.org>> 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? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > > It''s kind of "metaprogramming<http://en.wikipedia.org/wiki/metaprogramming>—creatingcode 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". This is citation from book Engineering Long-Lasting Software: An Agile Approach Using SaaS and Cloud Computing<http://www.amazon.com/dp/B006WU5G4C> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 3 September 2012 19:08, John Merlino <stoici...-YDxpq3io04c@public.gmane.org> wrote: > > > 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? > > It is a basic feature of Ruby that you can re-open a class definition > and add or redefine methods. > > Colin-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
uma mahesh varma Seeram
2012-Sep-04 05:02 UTC
Re: ActionView module declared several times
The metaprogramming nature of ruby is the most advantage feature of ruby. Thank You, Uma Mahesh. On Tuesday, September 4, 2012 7:01:32 AM UTC+5:30, John Merlino wrote:> > 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...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > On 3 September 2012 19:08, John Merlino <stoici...-YDxpq3io04c@public.gmane.org> wrote: > > > > > 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? > > > > It is a basic feature of Ruby that you can re-open a class definition > > and add or redefine methods. > > > > Colin >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/RT7CLUhIqqoJ. For more options, visit https://groups.google.com/groups/opt_out.