Class: Invitation::InvitesController::InviteForm
- Inherits:
-
Object
- Object
- Invitation::InvitesController::InviteForm
- Includes:
- ActiveModel::Model
- Defined in:
- app/controllers/invitation/invites_controller.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.
66 67 68 69 |
# File 'app/controllers/invitation/invites_controller.rb', line 66 def initialize(attributes = {}) @emails ||= [] super end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
59 60 61 |
# File 'app/controllers/invitation/invites_controller.rb', line 59 def email @email end |
#emails ⇒ Object
Returns the value of attribute emails.
59 60 61 |
# File 'app/controllers/invitation/invites_controller.rb', line 59 def emails @emails end |
#invitable ⇒ Object (readonly)
Returns the value of attribute invitable.
60 61 62 |
# File 'app/controllers/invitation/invites_controller.rb', line 60 def invitable @invitable end |
#invitable_id ⇒ Object
Returns the value of attribute invitable_id.
59 60 61 |
# File 'app/controllers/invitation/invites_controller.rb', line 59 def invitable_id @invitable_id end |
#invitable_type ⇒ Object
Returns the value of attribute invitable_type.
59 60 61 |
# File 'app/controllers/invitation/invites_controller.rb', line 59 def invitable_type @invitable_type end |
Class Method Details
.model_name ⇒ Object
form masquerades as ‘invite’
62 63 64 |
# File 'app/controllers/invitation/invites_controller.rb', line 62 def self.model_name # form masquerades as 'invite' ActiveModel::Name.new(self, nil, 'Invite') end |
Instance Method Details
#build_invites(current_user) ⇒ Object
75 76 77 78 79 |
# File 'app/controllers/invitation/invites_controller.rb', line 75 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 |