class RHC::Rest::Membership::Member
Public Instance Methods
<=>(other)
click to toggle source
# File lib/rhc/rest/membership.rb, line 62 def <=>(other) [role_weight, type, name, id] <=> [other.role_weight, other.type, other.name, other.id] end
admin?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 11 def admin? role == 'admin' end
editor?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 15 def editor? role == 'edit' end
explicit_role?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 35 def explicit_role? explicit_role.present? end
from()
click to toggle source
# File lib/rhc/rest/membership.rb, line 39 def from Array(attributes['from']) end
grant_from?(type, id)
click to toggle source
# File lib/rhc/rest/membership.rb, line 43 def grant_from?(type, id) from.detect {|f| f['type'] == type && f['id'] == id} end
name()
click to toggle source
# File lib/rhc/rest/membership.rb, line 27 def name attributes['name'] || login end
owner?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 7 def owner? !!owner end
role_weight()
click to toggle source
# File lib/rhc/rest/membership.rb, line 66 def role_weight if owner? 0 else case role when 'admin' then 1 when 'edit' then 2 when 'view' then 3 else 4 end end end
team?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 23 def team? type == 'team' end
teams(members)
click to toggle source
# File lib/rhc/rest/membership.rb, line 47 def teams(members) team_ids = from.inject([]) {|ids, f| ids << f['id'] if f['type'] == 'team'; ids } members.select {|m| m.team? && team_ids.include?(m.id) } end
to_s()
click to toggle source
# File lib/rhc/rest/membership.rb, line 52 def to_s if name == login "#{login} (#{role})" elsif login "#{name} <#{login}> (#{role})" else "#{name} (#{role})" end end
type()
click to toggle source
# File lib/rhc/rest/membership.rb, line 31 def type attributes['type'] || 'user' end
viewer?()
click to toggle source
# File lib/rhc/rest/membership.rb, line 19 def viewer? role == 'view' end