Skip to content

Instantly share code, notes, and snippets.

@almaron
Created July 16, 2013 21:50
Show Gist options
  • Select an option

  • Save almaron/6015466 to your computer and use it in GitHub Desktop.

Select an option

Save almaron/6015466 to your computer and use it in GitHub Desktop.
def get_auth
auths = {}
self.authentications.each { |auth| auths[auth.provider] = auth.id }
auths
end
@almaron
Copy link
Author

almaron commented Jul 16, 2013

Need a way to shorten this to one line.

@mwlang
Copy link

mwlang commented Jul 16, 2013

def get_auth
{}.tap{|t| self.authentications.each { |auth| t[auth.provider] = auth.id }}
end

@soulcutter
Copy link

self.authentications.inject({}) { |auths, auth| auths[auth.provider] = auth.id; auths }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment