Module: MuckInvites::Models::MuckInviter
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/muck-invites/models/inviter.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #invite(emails, message, user) ⇒ Object
-
#invitee_emails ⇒ Object
Gets all emails have been invited.
- #inviters ⇒ Object
-
#notify_inviters(invite_id = nil) ⇒ Object
Sends out notification email and adds an activity to each of the inviters activity feeds.
- #send_invited_joined_emails(inviters) ⇒ Object
Instance Method Details
#invite(emails, message, user) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/muck-invites/models/inviter.rb', line 46 def invite(emails, , user) emails = emails.split(/[, ]/) if !emails.is_a?(Array) emails = emails.find_all { |email| !email.blank? } emails = emails.flatten.collect { |email| email.strip } raise MuckInvites::Exceptions::NoEmails.new(I18n.t('muck.invites.no_email_error')) if emails.blank? check_emails = invitee_emails emails.each do |email| if !check_emails.include?(email) check_emails << email invitee = Invitee.find_by_email(email) || Invitee.create!(:email => email) Invite.create!(:inviter => self, :invitee => invitee, :user => user) response = InviteMailer.invite_notification(user, , email).deliver end end end |
#invitee_emails ⇒ Object
Gets all emails have been invited
26 27 28 |
# File 'lib/muck-invites/models/inviter.rb', line 26 def invitee_emails invitees.map(&:email) end |
#inviters ⇒ Object
63 64 65 |
# File 'lib/muck-invites/models/inviter.rb', line 63 def inviters Invite.who_invited?(self.email) end |
#notify_inviters(invite_id = nil) ⇒ Object
Sends out notification email and adds an activity to each of the inviters activity feeds
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/muck-invites/models/inviter.rb', line 31 def notify_inviters(invite_id = nil) inviters = Invitee.who_invited?(self.email, invite_id) if inviters.size > 0 content = I18n.t('muck.activities.joined_status', :name => self.full_name, :application_name => MuckEngine.configuration.application_name) inviters.each do |inviter| add_activity(self, self, self, 'status_update', '', content) if MuckInvites.configuration.create_activities_when_invited_joins send_invited_joined_emails(inviters) if MuckInvites.configuration.email_inviters_when_invited_joins end end end |
#send_invited_joined_emails(inviters) ⇒ Object
42 43 44 |
# File 'lib/muck-invites/models/inviter.rb', line 42 def send_invited_joined_emails(inviters) end |