frizbe1605
2011-Jun-06 14:34 UTC
Does anyone know how to access a module namespace using a chained method?
EngineBlogPost == @blog.engine_blog_post Engine::BlogPost == ???????? Thanks! -- 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.
Frederick Cheung
2011-Jun-06 18:35 UTC
Re: Does anyone know how to access a module namespace using a chained method?
On Jun 6, 3:34 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> EngineBlogPost == @blog.engine_blog_post > Engine::BlogPost == ???????? >You might want to elaborate - to me at least your question makes no sense. Fred.> Thanks!-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
frizbe1605
2011-Jun-07 14:16 UTC
Re: Does anyone know how to access a module namespace using a chained method?
Okay, I''m chaining methods. I want access to my class. I can access SomeClass with a method like some_class. Now with engines in Rails 3.1, I can use modules to break apart my codebase. So now, SomeClass would be Engine::SomeClass. If I try to access Engine::SomeClass with a similar style method like engine_some_class, it returns with EngineSomeClass rather than Engine::SomeClass. Any ideas on a chainable method for accessing this class now that it has the additional module namespace? Thanks, Steve On Jun 6, 1:35 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 6, 3:34 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> EngineBlogPost == @blog.engine_blog_post > > Engine::BlogPost == ???????? > > You might want to elaborate - to me at least your question makes no > sense. > > Fred. > > > > > > > > > Thanks!-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Kendall Gifford
2011-Jun-07 18:53 UTC
Re: Does anyone know how to access a module namespace using a chained method?
On Tuesday, June 7, 2011 8:16:02 AM UTC-6, frizbe1605 wrote:> > Okay, I''m chaining methods. I want access to my class.Access your class as in: obj.class (or something else)?> I can access > SomeClass with a method like some_class.Do you mean you can take a string "some_class" and call: "some_class".camelize.constantize => SomeClass Or, are you talking about some weird #method_missing-based feature of rails that I don''t know about?> Now with engines in Rails > 3.1, I can use modules to break apart my codebase.Well, in general terms, with ruby you''ve always been able to "break apart" your codebase using modules...> So now, SomeClass > would be Engine::SomeClass. If I try to access Engine::SomeClass with > a similar style method like engine_some_class, it returns with > EngineSomeClass rather than Engine::SomeClass. >So, I think the real question is, what do you mean by "it" in "it returns with..."? What method are you calling? If I had to guess, it looks to me like you''re not talking so much about calling a method #engine_some_class so much as passing this as a value (string or symbol) to some method. Am I on the right track?> > Any ideas on a chainable method for accessing this class now that it > has the additional module namespace? >What do you mean by chainable here? Do you mean method chaining like: obj.method_a.method_b.method_c(arg1, arg2).method_d On Jun 6, 1:35 pm, Frederick Cheung <frederic...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote: > > On Jun 6, 3:34 pm, frizbe1605 <frizb...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > EngineBlogPost == @blog.engine_blog_post > > > Engine::BlogPost == ???????? > > > > You might want to elaborate - to me at least your question makes no > > sense. > > > > Fred. > > >You need more elaboration still. I, like Fred, am still having a hard time knowing what you''re getting at. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/TlpZQlNnSEIzQUVK. 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.
Frederick Cheung
2011-Jun-08 16:35 UTC
Re: Does anyone know how to access a module namespace using a chained method?
On Jun 7, 3:16 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Okay, I''m chaining methods. I want access to my class. I can access > SomeClass with a method like some_class. Now with engines in Rails > 3.1, I can use modules to break apart my codebase. So now, SomeClass > would beEngine::SomeClass. If I try to accessEngine::SomeClass with > a similar style method like engine_some_class, it returns with > EngineSomeClass rather thanEngine::SomeClass.I think you are expecting magic where there is none. If your blog model has belogns_to :blog_post, ... then you''ll always do Blog.first.blog_post, whether blog_post is a BlogPost, Engine::BlogPost or some other class altogether Fred> > Any ideas on a chainable method for accessing this class now that it > has the additional module namespace? > > Thanks, > > Steve > > On Jun 6, 1:35 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On Jun 6, 3:34 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> EngineBlogPost == @blog.engine_blog_post > > >Engine::BlogPost == ???????? > > > You might want to elaborate - to me at least your question makes no > > sense. > > > Fred. > > > > Thanks!-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
frizbe1605
2011-Jun-08 19:23 UTC
Re: Does anyone know how to access a module namespace using a chained method?
If I call Engine::BlogPost everything is gravy, If I call BlogPost then I get... uninitialized constant BlogPost On Jun 8, 11:35 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jun 7, 3:16 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Okay, I''m chaining methods. I want access to my class. I can access > > SomeClass with a method like some_class. Now with engines in Rails > > 3.1, I can use modules to break apart my codebase. So now, SomeClass > > would beEngine::SomeClass. If I try to accessEngine::SomeClass with > > a similar style method like engine_some_class, it returns with > > EngineSomeClass rather thanEngine::SomeClass. > > I think you are expecting magic where there is none. If your blog > model has belogns_to :blog_post, ... then you''ll always do > Blog.first.blog_post, whether blog_post is a BlogPost, > Engine::BlogPost or some other class altogether > > Fred > > > > > > > > > > > Any ideas on a chainable method for accessing this class now that it > > has the additional module namespace? > > > Thanks, > > > Steve > > > On Jun 6, 1:35 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On Jun 6, 3:34 pm, frizbe1605 <frizbe1...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> EngineBlogPost == @blog.engine_blog_post > > > >Engine::BlogPost == ???????? > > > > You might want to elaborate - to me at least your question makes no > > > sense. > > > > Fred. > > > > > Thanks!-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.