Module: Hyrax::TwitterPresenter

Defined in:
app/presenters/hyrax/twitter_presenter.rb

Overview

Note:

The duplication of code was found via the flay gem

Repeatable logic for presenting twitter handles.

Class Method Summary collapse

Class Method Details

.twitter_handle_for(user_key:) ⇒ String

Returns the twitter handle appropriate for the given user key.

Parameters:

  • user_key (String)

    for which we will find the appropriate twitter handle

Returns:

  • (String)

    the twitter handle appropriate for the given user key



10
11
12
13
14
15
16
17
# File 'app/presenters/hyrax/twitter_presenter.rb', line 10

def self.twitter_handle_for(user_key:)
  user = ::User.find_by_user_key(user_key)
  if user.try(:twitter_handle).present?
    "@#{user.twitter_handle}"
  else
    I18n.translate('hyrax.product_twitter_handle')
  end
end