Class: Swivel::Group

Inherits:
Response show all
Defined in:
lib/swivel.rb

Instance Attribute Summary

Attributes inherited from Response

#disable_auto_refresh, #hash_doc, #refreshed_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#[], #id, #initialize, #method_missing, #to_s, #to_xml

Constructor Details

This class inherits a constructor from Swivel::Response

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Swivel::Response

Class Method Details

.resourceObject



489
490
491
# File 'lib/swivel.rb', line 489

def self.resource
  'group'
end

Instance Method Details

#has_admin?(member) ⇒ Boolean

Returns:

  • (Boolean)


503
504
505
506
# File 'lib/swivel.rb', line 503

def has_admin?(member)
  permission = permission_for(member)
  permission and permission.rights == ::Permission::WRITE
end

#has_member?(member) ⇒ Boolean

Returns:

  • (Boolean)


508
509
510
# File 'lib/swivel.rb', line 508

def has_member?(member)
  !!permission_for(member)
end

#permission_for(member) ⇒ Object



495
496
497
498
499
500
501
502
# File 'lib/swivel.rb', line 495

def permission_for(member)
  raise 'group has no permissions' unless permissions
  perm = permissions.find do |p|
    p.accessor_id == member.id and
    p.accessor_type == member.class.name.sub(/^Swivel::/,'')
  end
  perm
end

#to_paramObject



492
493
494
# File 'lib/swivel.rb', line 492

def to_param
  (!slug.blank? and slug) or super.to_param
end