class Model < ActiveRecord::Base def singleton class << self self end end end>> m = Model.new >> m.singleton >> SystemStackError: stack level too deep..<a href="http://pastie.org/private/8okkiajm0qwfiwulxg3tjw">See the complete error.</a> Why is this? -- Posted via http://www.ruby-forum.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 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 13 May 2010 21:57, Daniel Waite <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>>> m = Model.new >>> m.singleton >>> SystemStackError: stack level too deep.. > > Why is this?Where did you get that from as a method for creating singletons? Try this instead: http://www.railsrocket.com/articles/singleton-classes -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Michael Pavling wrote:> On 13 May 2010 21:57, Daniel Waite <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> m = Model.new >>>> m.singleton >>>> SystemStackError: stack level too deep.. >> >> Why is this? > > Where did you get that from as a method for creating singletons? > > Try this instead: > http://www.railsrocket.com/articles/singleton-classesThat''s the Singleton pattern. I think the OP wanted to know how to get a model''s singleton class (eigenclass). Unfortunate coincidence of terminology for two completely different things. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.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 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> Marnen Laibow-Koser wrote: > > That''s the Singleton pattern. I think the OP wanted to know how to get > a model''s singleton class (eigenclass).Correct.> Unfortunate coincidence of terminology for two completely different things.Agreed. On a hunch, I looked up Black''s precise terminology in The Well-Grounded Rubyist and he defines his method like so: def singleton_class ... I believe some level of confusion may have been avoided had I written as he did. Anywho. So, Marnen, any idea why AR-inheriting objects do this? -- Posted via http://www.ruby-forum.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 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.