Module: MyGravatar::FormHelpers
- Defined in:
- lib/my_gravatar/form_helpers.rb
Instance Method Summary collapse
- #gravatar_image_tag(options = {}) ⇒ Object
-
#process_gravatar_options(opts) ⇒ Object
secure, email, size, default_image, rating.
Instance Method Details
#gravatar_image_tag(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/my_gravatar/form_helpers.rb', line 4 def gravatar_image_tag( = {}) raise "Please specify gravatar options." unless [:gravatar] raise "Please specify gravatar email." unless [:gravatar][:email] source, = () image_tag(source, ) end |
#process_gravatar_options(opts) ⇒ Object
secure, email, size, default_image, rating
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/my_gravatar/form_helpers.rb', line 14 def (opts) host = GravatarExtensions.url(opts[:gravatar][:secure] ||= false) hash = GravatarExtensions.account_key(opts[:gravatar][:email]) url_params = [] ["size", "default_image", "rating"].each do |k| key = GravatarExtensions.gravatar_param_key(k) value = opts[:gravatar][k.to_sym] ||= GravatarExtensions.gravatar_default_value(k) url_params << "#{key}=#{value}" end url = [] url << host url << hash url << url_params.join("/") opts.delete(:gravatar) #remove the gravatar option return url.join("/"), opts end |