Created
September 29, 2015 19:50
-
-
Save sighmin/665903bed43d405fc78e to your computer and use it in GitHub Desktop.
This file contains 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
module ViewHelpers | |
def urls | |
Rails.application.routes.url_helpers | |
end | |
def helpers | |
ActionController::Base.helpers | |
end | |
end | |
class UserView < SimpleDelegator | |
include ViewHelpers | |
def initialize(delegate, salutation: 'Padawan') | |
super(delegate) | |
@salutation = salutation | |
end | |
def fullname | |
"#{salutation} #{first_name} #{last_name}" | |
end | |
def master_users_path | |
helpers.link_to "MAASTERS", urls.users_path(skill: 'master') | |
end | |
private | |
attr_reader :salutation | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment