Peta Ward
2012-Dec-08 12:29 UTC
Re: Digest for rubyonrails-core@googlegroups.com - 5 Messages in 1 Topic
This is a delivery failure notification message indicating that an email you sent could not be delivered. The problem appears to be : -- Recipient email server rejected the message This condition occurred after 1 attempt(s) to deliver over a period of 0 hour(s). If you sent the email to multiple recipients, you will receive one of these messages for each one which failed delivery, otherwise they have been sent. On 8 Dec 2012, at 12:27, rubyonrails-core@googlegroups.com wrote:> Today''s Topic Summary > Group: http://groups.google.com/group/rubyonrails-core/topics > • undefining constants on class autoload? [5 Updates] > undefining constants on class autoload? > • Gary Weaver <garysweaver@gmail.com> Dec 07 02:00PM -0800 > • > • This probably sounds crazy but has it even been considered to either have a > • way to register constants for an autoloaded class so they will be undefined > • before reload, or maybe even just a class method to do: > • > • def_const(:SOME_CONSTANT, value) > • > • that would: > • > • def def_const(constant, value) > • remove_const(constant) if const_defined?(constant) > • constant = value > • end > • > • Some say to put constants where they aren''t autoloaded (like in > • initializers) and other even suggest using methods, but that defeats the > • purpose of using constants. So does the method above, but it is more in > • line with what Rails autoloading promises. > • > • Seems like avoiding the problem makes some consider just using magic > • numbers in code which is like stepping back into time. > • > • Steve Klabnik <steve@steveklabnik.com> Dec 07 02:03PM -0800 > • > • The problem with this system is that it''s not normal Ruby, and if > • someone doesn''t use it, and uses Ruby, it all breaks. > • > • Michael Koziarski <michael@koziarski.com> Dec 08 11:04AM +1300 > • > • On Saturday, 8 December 2012 at 11:00 AM, Gary Weaver wrote: > • > • > end > • > • > Some say to put constants where they aren''t autoloaded (like in initializers) and other even suggest using methods, but that defeats the purpose of using constants. So does the method above, but it is more in line with what Rails autoloading promises. > • > • > Seems like avoiding the problem makes some consider just using magic numbers in code which is like stepping back into time. > • If they''re constants, that belong to the class, then make them constants inside the class: > • > • class MyModel < ActiveRecord::Model > • SOME_CONSTANT = 42 > • end > • > • That will reload correctly. > • > • > • > • Gary Weaver <garysweaver@gmail.com> Dec 07 02:13PM -0800 > • > • $ irb > • 1.9.3p194 :001 > class Class > • 1.9.3p194 :002?> def def_const(constant, value) > • 1.9.3p194 :003?> remove_const(constant) if const_defined?(constant) > • 1.9.3p194 :004?> const_set(constant, value) > • 1.9.3p194 :005?> end > • 1.9.3p194 :006?> end > • => nil > • 1.9.3p194 :007 > class Something > • 1.9.3p194 :008?> def_const(:HI, 1) > • 1.9.3p194 :009?> end > • => 1 > • 1.9.3p194 :010 > class Something > • 1.9.3p194 :011?> def_const(:HI, 1) > • 1.9.3p194 :012?> end > • => 1 > • 1.9.3p194 :013 > Something::HI > • => 1 > • > • Like that. > • > • On Friday, December 7, 2012 5:00:40 PM UTC-5, Gary Weaver wrote: > • > • Gary Weaver <garysweaver@gmail.com> Dec 07 02:45PM -0800 > • > • This is one of the things that got me concerned: > • http://devblog.avdi.org/2011/08/18/do-we-need-constants/ > • > • It''s neat, but seems wrong (no offense to those using that technique). > • > • On Friday, December 7, 2012 5:13:51 PM UTC-5, Gary Weaver wrote: > • > You received this message because you are subscribed to the Google Group rubyonrails-core. > You can post via email. > To unsubscribe from this group, send an empty message. > For more options, visit this group. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.