Hi guys I am thinking about new feature(maybe it already exists, in thie case let me know) Can you pelase review and provide some feedbacks, if you find it usefull of course We can put in inside active_support So i need define methods that return nil(or other value that is similar for all methods) [:title, :type].each do |name| define_method(name) { nil } end But i am thinking about smth like define_methods :title, :type # and it will generate same stuff and return nill define_methods :title. :type, return: false # generate methods and return false define_methods :title, :type do "extra logic" end # generate methods and return value that return block -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/n5CHwFdF06AJ. 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.
What is the usecase? What value does it provide ? How is it any better than ? def title; nil; end def type; nil; end Maybe it is just me but I totally do not get what your are trying to achieve. Robert Pankowecki -- 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.
In my case i have 4 methods that return nil, so explicit definition looks wierd for me. So that why i thought maybe such method will useful, at least to make code cleaner def method1; nil; end def method2; nil; end vs define_methods :method1, :method2, :method3, :method4 def method3; nil; end def method4; nil; end Четвер, 4 жовтня 2012 р. 14:35:50 UTC+3 користувач Robert Pankowecki написав:> > What is the usecase? What value does it provide ? How is it any better > than ? > > def title; nil; end > def type; nil; end > > > Maybe it is just me but I totally do not get what your are trying to > achieve. > > Robert Pankowecki >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/5DmvGbSVkYwJ. 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.
Thanks for your proposal, but it''s probably too narrow use case to extend rails with it. Also, it may look weird to do a few similar methods that just return nil, but at least it''s easy to understand - if I don''t know what does define_methods do, I would need to check implementation or documentation to understand this. In such case I think even such code would be better: %w/method1 method2 method3 method4/.each { |name| define_method(name) { nil } } It''s not much longer than define_methods that you proposed and you see what it does right way. On Thu, Oct 4, 2012 at 1:45 PM, Тіма Маслюченко <insside@gmail.com> wrote:> In my case i have 4 methods that return nil, so explicit definition looks > wierd for me. So that why i thought maybe such method will useful, at least > to make code cleaner > > def method1; nil; end > def method2; nil; end vs define_methods :method1, :method2, :method3, > :method4 > def method3; nil; end > def method4; nil; end > > Четвер, 4 жовтня 2012 р. 14:35:50 UTC+3 користувач Robert Pankowecki > написав: > >> What is the usecase? What value does it provide ? How is it any better >> than ? >> >> def title; nil; end >> def type; nil; end >> >> >> Maybe it is just me but I totally do not get what your are trying to >> achieve. >> >> Robert Pankowecki >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-core/-/5DmvGbSVkYwJ. > > 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. >-- Piotr Sarnacki http://piotrsarnacki.com -- 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.