soveran / cuba

Rum based microframework for web development.
http://cuba.is
MIT License
1.44k stars 248 forks source link

Take advantage of ruby 2.1's #def returns #34

Closed pote closed 10 years ago

pote commented 10 years ago

From Ruby 2.1 onwards the def method returns a symbol created from the method's name, allowing us to avoid a bit of repetition when declaring private methods.

## Ruby 2.0 < 
def foo; end
private :foo

## Ruby 2.1 > 
private def foo; end

This pull request shouldn't be merged until cuba stops supporting Ruby versions prior to 2.1, so I expect it to never be merged in practice.

I was super bored though.

cyx commented 10 years ago

Woah woah woah, advanced features :-)

Thanks, will check it out!

On Mon, Feb 24, 2014 at 2:57 PM, Pablo Astigarraga <notifications@github.com

wrote:

From Ruby 2.1 onwards the def method returns a symbol created from the method's name, allowing us to avoid a bit of repetition when declaring private methods.

Ruby 2.0 < def foo; endprivate :foo

Ruby 2.1 > private def foo; end

This pull request shouldn't be merged until cuba stops supporting Ruby versions prior to 2.1, so I expect it to never be merged in practice.

I was super bored though.

You can merge this Pull Request by running

git pull https://github.com/pote/cuba briefer_private_defs

Or view, comment on, or merge it at:

https://github.com/soveran/cuba/pull/34 Commit Summary

  • Take advantage of ruby 2.1's #def returns

File Changes

  • M lib/cuba.rbhttps://github.com/soveran/cuba/pull/34/files#diff-0(6)
  • M lib/cuba/render.rbhttps://github.com/soveran/cuba/pull/34/files#diff-1(3)

Patch Links:

Reply to this email directly or view it on GitHubhttps://github.com/soveran/cuba/pull/34 .

pote commented 10 years ago

Don't merge it or you'll break everything for everyone! :P

foca commented 10 years ago

private def foo? What is this? JAVA?

pote commented 10 years ago

It totally is.

rogeriozambon commented 10 years ago

This way of declaring a private method:

def foo; end
private :foo

Is set before Ruby 2.0. In my opinion, I don't think good to apply such a small change, only available in the latest version.

foca commented 10 years ago

@rogeriozambon totally! this whole PR was mostly a joke :)

soveran commented 10 years ago

I will close this for now, and reopen it in the future if we are still using Ruby.