Module: GroupedReader::InstanceMethods

Defined in:
lib/grouped_reader.rb

Instance Method Summary collapse

Instance Method Details

#activate_with_group!Object

if group-welcome messages exist for this reader’s memberships, they will be sent on activation



51
52
53
# File 'lib/grouped_reader.rb', line 51

def activate_with_group!
  send_group_welcomes if activate_without_group!
end

#can_see?(this) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
# File 'lib/grouped_reader.rb', line 32

def can_see? (this)
  permitted_groups = this.permitted_groups
  permitted_groups.empty? or in_any_of_these_groups?(permitted_groups)
end

#find_homepageObject



26
27
28
29
30
# File 'lib/grouped_reader.rb', line 26

def find_homepage
  if homegroup = groups.with_home_page.first
    homegroup.homepage
  end
end

#has_group?(group = nil) ⇒ Boolean

has_group? is ambiguous: with no argument it means ‘is this reader grouped at all?’.

Returns:

  • (Boolean)


46
47
48
# File 'lib/grouped_reader.rb', line 46

def has_group?(group=nil)
  group.nil? ? groups.any? : is_in?(group)
end

#in_any_of_these_groups?(grouplist) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/grouped_reader.rb', line 37

def in_any_of_these_groups? (grouplist)
  (grouplist & groups).any?
end

#is_in?(group) ⇒ Boolean

Returns:

  • (Boolean)


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

def is_in? (group)
  groups.include?(group)
end

#send_functional_message_with_group(function, group = nil) ⇒ Object

there may be versions of the functional (eg welcome) messages specific to a group (which has to be passed through, so this currently only happens when sending out group invitations but ought to be useful elsewhere too)



57
58
59
60
61
# File 'lib/grouped_reader.rb', line 57

def send_functional_message_with_group(function, group=nil)
  reset_perishable_token!
  message = Message.functional(function, group)   # returns the standard functional message if no group is supplied, or no group message exists
  message.deliver_to(self) if message
end

#send_group_invitation_message(group = nil) ⇒ Object



63
64
65
# File 'lib/grouped_reader.rb', line 63

def send_group_invitation_message(group=nil)
  send_functional_message_with_group('invitation', group)
end