Module: RolesHelper

Defined in:
app/helpers/roles_helper.rb

Instance Method Summary collapse

Instance Method Details

#role_in_project?(role) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'app/helpers/roles_helper.rb', line 24

def role_in_project?(role)
  Role.exists?(project_id: sessions_current_project_id, id: role.id)
end


12
13
14
15
# File 'app/helpers/roles_helper.rb', line 12

def role_link(role)
  return nil if role.nil?
  link_to(role_tag(role).html_safe, metamorphosize_if(role.role_object))
end

#role_object_tag(role) ⇒ String?

Returns the role followed by the object tag of the role_object, like ‘Taxon name author of Aus bus’.

Returns:

  • (String, nil)

    the role followed by the object tag of the role_object, like ‘Taxon name author of Aus bus’.



19
20
21
22
# File 'app/helpers/roles_helper.rb', line 19

def role_object_tag(role)
  return nil if role.nil?
  [role.class.human_name, object_tag(role.role_object)].join(' of ').html_safe
end

#role_tag(role) ⇒ Object



3
4
5
6
# File 'app/helpers/roles_helper.rb', line 3

def role_tag(role)
  return nil if role.nil?
  [role.person.cached, "[#{role.class.human_name}]"].join(' ').html_safe
end

#roles_names(roles) ⇒ Object



8
9
10
# File 'app/helpers/roles_helper.rb', line 8

def roles_names(roles)
  people_names(roles.collect{|p| p.person})
end