Skip to content

Commit 9cc28aa

Browse files
committed
🚚 Move Signup factory to Masq lib
1 parent 5902c61 commit 9cc28aa

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

app/models/masq/account.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def authenticate(login, password, basic_auth_used = false)
6161
else
6262
password
6363
end
64-
signup = Signup.create_account!(
64+
signup = Masq::Signup.create_account!(
6565
login: login,
6666
password: pw,
6767
password_confirmation: pw,

lib/masq.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Masq
1818
require_relative "masq/active_record_openid_store/association"
1919
require_relative "masq/active_record_openid_store/nonce"
2020
require_relative "masq/active_record_openid_store/openid_ar_store"
21+
require_relative "masq/signup"
2122
rescue StandardError, LoadError => e
2223
if !defined?(::Rails::Engine)
2324
warn("masq2 is a Rails engine, but Rails::Engine isn't defined.")
@@ -37,13 +38,6 @@ module Masq
3738
end
3839
end
3940

40-
require_relative "masq/engine"
41-
require_relative "masq/authenticated_system"
42-
require_relative "masq/openid_server_system"
43-
require_relative "masq/active_record_openid_store/association"
44-
require_relative "masq/active_record_openid_store/nonce"
45-
require_relative "masq/active_record_openid_store/openid_ar_store"
46-
4741
# Ensure version is configured before loading the rest of the library
4842
Masq::Version.class_eval do
4943
extend VersionGem::Basic

app/models/masq/signup.rb renamed to lib/masq/signup.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ module Masq
44
class Signup
55
attr_accessor :account
66

7-
def self.create_account!(attrs = {})
8-
signup = Signup.new(attrs)
9-
signup.send(:create_account!)
10-
signup
7+
class << self
8+
def create_account!(attrs = {})
9+
factory = new(attrs)
10+
factory.send(:create_account!)
11+
factory
12+
end
1113
end
1214

1315
def succeeded?
@@ -21,16 +23,17 @@ def send_activation_email?
2123
protected
2224

2325
def initialize(attrs = {})
24-
self.account = Account.new(attrs)
26+
self.account = Masq::Account.new(attrs)
2527
end
2628

2729
def create_account!
2830
return false unless account.valid?
31+
2932
make_activation_code if send_activation_email?
3033
account.save!
3134
make_default_persona
3235
if send_activation_email?
33-
AccountMailer.signup_notification(account).deliver_now
36+
Masq::AccountMailer.signup_notification(account).deliver_now
3437
else
3538
account.activate!
3639
end

0 commit comments

Comments
 (0)