Class: Invitation

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/invitation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#existing_user_emailObject



42
43
44
# File 'app/models/invitation.rb', line 42

def existing_user_email
  @existing_user_email ||= email
end

#existing_user_passwordObject

Returns the value of attribute existing_user_password.



11
12
13
# File 'app/models/invitation.rb', line 11

def existing_user_password
  @existing_user_password
end

#new_user_emailObject



38
39
40
# File 'app/models/invitation.rb', line 38

def new_user_email
  @new_user_email ||= email
end

#new_user_nameObject

Returns the value of attribute new_user_name.



11
12
13
# File 'app/models/invitation.rb', line 11

def new_user_name
  @new_user_name
end

#new_user_passwordObject

Returns the value of attribute new_user_password.



11
12
13
# File 'app/models/invitation.rb', line 11

def new_user_password
  @new_user_password
end

#new_user_password_confirmationObject

Returns the value of attribute new_user_password_confirmation.



11
12
13
# File 'app/models/invitation.rb', line 11

def new_user_password_confirmation
  @new_user_password_confirmation
end

#userObject (readonly)

Returns the value of attribute user.



14
15
16
# File 'app/models/invitation.rb', line 14

def user
  @user
end

Instance Method Details

#accept(attributes) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/invitation.rb', line 23

def accept(attributes)
  self.attributes = attributes
  self.used = true
  @user = existing_user || new_user
  if valid?
    transaction do
      save!
      @user.save!
      @user.memberships.create!(:account  => ,
                                :admin    => admin,
                                :projects => projects)
    end
  end
end

#account_nameObject



19
20
21
# File 'app/models/invitation.rb', line 19

def 
  .name
end

#sender_emailObject



54
55
56
# File 'app/models/invitation.rb', line 54

def sender_email
  sender.email
end

#sender_nameObject



50
51
52
# File 'app/models/invitation.rb', line 50

def sender_name
  sender.name
end

#to_paramObject



46
47
48
# File 'app/models/invitation.rb', line 46

def to_param
  code
end