You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
574 B

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