Class: PagesCore::InviteService
- Inherits:
-
Object
- Object
- PagesCore::InviteService
- Defined in:
- app/services/pages_core/invite_service.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(attributes, user:, host:, protocol: "http") ⇒ InviteService
constructor
A new instance of InviteService.
Constructor Details
#initialize(attributes, user:, host:, protocol: "http") ⇒ InviteService
Returns a new instance of InviteService.
9 10 11 12 13 14 |
# File 'app/services/pages_core/invite_service.rb', line 9 def initialize(attributes, user:, host:, protocol: "http") @attributes = attributes @user = user @host = host @protocol = protocol end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
7 8 9 |
# File 'app/services/pages_core/invite_service.rb', line 7 def attributes @attributes end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
7 8 9 |
# File 'app/services/pages_core/invite_service.rb', line 7 def host @host end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
7 8 9 |
# File 'app/services/pages_core/invite_service.rb', line 7 def protocol @protocol end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'app/services/pages_core/invite_service.rb', line 7 def user @user end |
Class Method Details
.call(attrs, user:, host:, protocol: "http") ⇒ Object
17 18 19 |
# File 'app/services/pages_core/invite_service.rb', line 17 def call(attrs, user:, host:, protocol: "http") new(attrs, user: user, host: host, protocol: protocol).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/services/pages_core/invite_service.rb', line 22 def call Invite.transaction do invite = user.invites.create(attributes) if invite.valid? deliver_invite(invite) invite.update(sent_at: Time.now.utc) end invite end end |