Class: Pageflow::InvitationForm Private
- Inherits:
-
Object
- Object
- Pageflow::InvitationForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/models/pageflow/invitation_form.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #available_accounts ⇒ Object readonly private
- #membership ⇒ Object readonly private
- #target_user ⇒ Object readonly private
Instance Method Summary collapse
- #existing_member ⇒ Object private
- #initial_account ⇒ Object private
-
#initialize(attributes, available_accounts) ⇒ InvitationForm
constructor
private
A new instance of InvitationForm.
- #save ⇒ Object private
- #user ⇒ Object private
- #valid? ⇒ Boolean private
Constructor Details
#initialize(attributes, available_accounts) ⇒ InvitationForm
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of InvitationForm.
8 9 10 11 12 13 14 15 16 17 |
# File 'app/models/pageflow/invitation_form.rb', line 8 def initialize(attributes, available_accounts) @attributes = attributes @available_accounts = available_accounts @invited_user = InvitedUser.new(attributes[:user]) @target_user = existing_user || @invited_user @membership = @target_user.memberships.build(entity: initial_account, role: initial_role) end |
Instance Attribute Details
#available_accounts ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'app/models/pageflow/invitation_form.rb', line 6 def available_accounts @available_accounts end |
#membership ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'app/models/pageflow/invitation_form.rb', line 6 def membership @membership end |
#target_user ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 |
# File 'app/models/pageflow/invitation_form.rb', line 6 def target_user @target_user end |
Instance Method Details
#existing_member ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 |
# File 'app/models/pageflow/invitation_form.rb', line 34 def existing_member @existing_member ||= initial_account && initial_account.users.find_by_email(user.email) end |
#initial_account ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 46 |
# File 'app/models/pageflow/invitation_form.rb', line 39 def initial_account @initial_account ||= if initial_account_id available_accounts.find_by_id(initial_account_id) else available_accounts.first end end |
#save ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 |
# File 'app/models/pageflow/invitation_form.rb', line 23 def save return false unless valid? Pageflow.config.quotas.get(:users, initial_account).verify_available! membership.save! end |
#user ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'app/models/pageflow/invitation_form.rb', line 19 def user @invited_user.becomes(User) end |
#valid? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'app/models/pageflow/invitation_form.rb', line 30 def valid? (existing_user || @invited_user.valid?) && membership.valid? end |