Class: Invitation::InviteForm
- Inherits:
-
Object
- Object
- Invitation::InviteForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/forms/invitation/invite_form.rb
Overview
A form object pretends to be ‘invite’, but accepts both ‘email’ and ‘emails’. It knows how to build all of the invite instances.
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#emails ⇒ Object
Returns the value of attribute emails.
-
#invitable ⇒ Object
readonly
Returns the value of attribute invitable.
-
#invitable_id ⇒ Object
Returns the value of attribute invitable_id.
-
#invitable_type ⇒ Object
Returns the value of attribute invitable_type.
Class Method Summary collapse
-
.model_name ⇒ Object
form masquerades as ‘invite’.
Instance Method Summary collapse
- #build_invites(current_user) ⇒ Object
-
#initialize(attributes = {}) ⇒ InviteForm
constructor
A new instance of InviteForm.
Constructor Details
#initialize(attributes = {}) ⇒ InviteForm
Returns a new instance of InviteForm.
15 16 17 18 |
# File 'app/forms/invitation/invite_form.rb', line 15 def initialize(attributes = {}) @emails ||= [] super end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'app/forms/invitation/invite_form.rb', line 8 def email @email end |
#emails ⇒ Object
Returns the value of attribute emails.
8 9 10 |
# File 'app/forms/invitation/invite_form.rb', line 8 def emails @emails end |
#invitable ⇒ Object (readonly)
Returns the value of attribute invitable.
9 10 11 |
# File 'app/forms/invitation/invite_form.rb', line 9 def invitable @invitable end |
#invitable_id ⇒ Object
Returns the value of attribute invitable_id.
8 9 10 |
# File 'app/forms/invitation/invite_form.rb', line 8 def invitable_id @invitable_id end |
#invitable_type ⇒ Object
Returns the value of attribute invitable_type.
8 9 10 |
# File 'app/forms/invitation/invite_form.rb', line 8 def invitable_type @invitable_type end |
Class Method Details
.model_name ⇒ Object
form masquerades as ‘invite’
11 12 13 |
# File 'app/forms/invitation/invite_form.rb', line 11 def self.model_name # form masquerades as 'invite' ActiveModel::Name.new(self, nil, 'Invite') end |
Instance Method Details
#build_invites(current_user) ⇒ Object
24 25 26 27 28 |
# File 'app/forms/invitation/invite_form.rb', line 24 def build_invites(current_user) all_emails.reject(&:blank?).collect do |e| Invite.new(invitable_id: @invitable_id, invitable_type: @invitable_type, sender_id: current_user.id, email: e) end end |