engine/app/presenters/locomotive/membership_presenter.rb

33 lines
637 B
Ruby
Raw Normal View History

module Locomotive
class MembershipPresenter < BasePresenter
delegate :role, :to => :source
def name
self.source.account.name
end
def role_name
I18n.t("locomotive.memberships.roles.#{self.source.role}")
end
def email
self.source.account.email
end
def can_update
return nil unless self.ability?
self.ability.can? :update, self.source
end
def grant_admin
return nil unless self.ability?
self.ability.can? :grant_admin, self.source
end
def included_methods
super + %w(name email role role_name can_update grant_admin)
end
end
end