Class: Locomotive::MembershipPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/locomotive/membership_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#ability, #depth

Instance Method Summary collapse

Methods inherited from BasePresenter

#ability?, #after_initialize, getters_to_hash, #id, setters_to_hash, #site

Methods included from Presentable

#after_initialize, #as_json, #attributes=, #getters, #initialize, #property_options, #setters

Instance Method Details

#can_updateObject



25
26
27
28
# File 'app/presenters/locomotive/membership_presenter.rb', line 25

def can_update
  return nil unless self.ability?
  self.ability.can? :update, self.source
end

#emailObject



21
22
23
# File 'app/presenters/locomotive/membership_presenter.rb', line 21

def email
  self.source..email
end

#grant_adminObject



30
31
32
33
# File 'app/presenters/locomotive/membership_presenter.rb', line 30

def grant_admin
  return nil unless self.ability?
  self.ability.can? :grant_admin, self.source
end

#nameObject

other getters / setters ##



13
14
15
# File 'app/presenters/locomotive/membership_presenter.rb', line 13

def name
  self.source..name
end

#roleObject

properties ##



6
# File 'app/presenters/locomotive/membership_presenter.rb', line 6

property    :role

#role_nameObject



17
18
19
# File 'app/presenters/locomotive/membership_presenter.rb', line 17

def role_name
  I18n.t("locomotive.memberships.roles.#{self.source.role}")
end