migration.rb 535 B

12345678910111213141516171819202122232425
  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