logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

migration.rb (535B)


  1. # frozen_string_literal: true
  2. class Form::Migration
  3. include ActiveModel::Validations
  4. attr_accessor :acct, :account
  5. def initialize(attrs = {})
  6. @account = attrs[:account]
  7. @acct = attrs[:account].acct unless @account.nil?
  8. @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil?
  9. end
  10. def valid?
  11. return false unless super
  12. set_account
  13. errors.empty?
  14. end
  15. private
  16. def set_account
  17. self.account = (ResolveAccountService.new.call(acct) if account.nil? && acct.present?)
  18. end
  19. end