Class: Aker::GroupMembership

Inherits:
Object
  • Object
show all
Defined in:
lib/aker/group_membership.rb

Overview

The authority-independent representation of a user's association with a particular group, possibly constrained by affiliate.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (GroupMembership) initialize(group)

Create a new instance.

Parameters:

  • group (Group)

    the group for which this object records membership



24
25
26
# File 'lib/aker/group_membership.rb', line 24

def initialize(group)
  @group = group
end

Instance Attribute Details

- (Array<Object>) affiliate_ids

The affiliate IDs to which this membership is scoped. If this array is blank or nil, the membership applies to all affiliates.

An "affiliate" is an arbitrary scope designator for a membership. The specific form will depend on the authority that is authorizing the user.

Returns:

  • (Array<Object>)


17
18
19
# File 'lib/aker/group_membership.rb', line 17

def affiliate_ids
  @affiliate_ids ||= []
end

Instance Method Details

- (Group) group

Returns the group for which this is a membership

Returns:

  • (Group)

    the group for which this is a membership



47
48
49
# File 'lib/aker/group_membership.rb', line 47

def group
  @group
end

- (String) group_name

Returns the name of the group for which this object indicates membership.

Returns:

  • (String)

    the name of the group for which this object indicates membership.



41
42
43
# File 'lib/aker/group_membership.rb', line 41

def group_name
  self.group.name
end

- (Boolean) include_affiliate?(affiliate_id)

Determines whether this membership applies to the given affiliate.

Parameters:

  • affiliate_id (Object)

Returns:

  • (Boolean)


34
35
36
# File 'lib/aker/group_membership.rb', line 34

def include_affiliate?(affiliate_id)
  affiliate_ids.blank? ? true : affiliate_ids.include?(affiliate_id)
end