Created
December 8, 2014 08:36
-
-
Save KamilLelonek/55b36aac2a965988c4ac to your computer and use it in GitHub Desktop.
GravatarHelper that can be used directly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/md5' | |
module GravatarHelper | |
# previous implementation | |
# ... | |
def gravatar_for_email(email) | |
self.class.gravatar_for_email(email) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[0] (pry) main: 0> user = User.new('[email protected]'); | |
[1] (pry) main: 0> GravatarHelper.gravatar_for_email(user.email) | |
=> 'http://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
attr_reader :email | |
def initialize(email) | |
@email = email | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment