diff options
author | David Yip <yipdw@member.fsf.org> | 2017-12-04 11:07:01 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-12-04 11:07:01 -0600 |
commit | d9800a5647cbc57db7679094b2271f8eb5ec328b (patch) | |
tree | f9210c465de5f9d80e294d9ffa8536f98f9c466e /app/models/form/migration.rb | |
parent | 1c74ede69e7a9916c19da6f05daa215231eba81c (diff) | |
parent | f2f2f1032082d6212771bd0307136484f671d37e (diff) |
Merge branch 'gs-master' into glitch-theme
Diffstat (limited to 'app/models/form/migration.rb')
-rw-r--r-- | app/models/form/migration.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/models/form/migration.rb b/app/models/form/migration.rb new file mode 100644 index 000000000..b74987337 --- /dev/null +++ b/app/models/form/migration.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class Form::Migration + include ActiveModel::Validations + + attr_accessor :acct, :account + + def initialize(attrs = {}) + @account = attrs[:account] + @acct = attrs[:account].acct unless @account.nil? + @acct = attrs[:acct].gsub(/\A@/, '').strip unless attrs[:acct].nil? + end + + def valid? + return false unless super + set_account + errors.empty? + end + + private + + def set_account + self.account = (ResolveRemoteAccountService.new.call(acct) if account.nil? && acct.present?) + end +end |