class Ecko::Plugins::Sponsor::Donated

Attributes

account[RW]
intent[RW]
package[RW]

Public Class Methods

new(intent) click to toggle source

Sets the intent of the donation and finds account and package with whom the intent is related to.

# File lib/ecko/plugins/sponsor/donated.rb, line 13
def initialize(intent)
  @intent = intent
  @account = ::Account.find(intent.payable_id)
  @package = ::DonationPackage.find(intent.metadata['package_id'])
end

Private Class Methods

process(intent) click to toggle source
# File lib/ecko/plugins/sponsor/donated.rb, line 42
def process(intent)
  new(intent).process
end

Public Instance Methods

process() click to toggle source

Just the processor.

# File lib/ecko/plugins/sponsor/donated.rb, line 20
def process
  create_donation && update_account_sponsorship && close_intent
end

Private Instance Methods

close_intent() click to toggle source

Close the intent that was used for the donation

# File lib/ecko/plugins/sponsor/donated.rb, line 32
def close_intent
  intent.update(status: 'closed')
end
create_donation() click to toggle source

When the donation has been made, Create a donation for the account.

# File lib/ecko/plugins/sponsor/donated.rb, line 37
def create_donation
  ::Donation.create(account: account, amount: package.amount)
end
update_account_sponsorship() click to toggle source

This is to help donations

# File lib/ecko/plugins/sponsor/donated.rb, line 27
def update_account_sponsorship
  account.refresh_sponsorship
end