Class: Hello::Business::Registration::SignUp
- Defined in:
- lib/hello/business/registration/sign_up.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#email_taken? ⇒ Boolean
errors.added? DOES NOT WORK when the validation was given a custom message :).
-
#initialize ⇒ SignUp
constructor
A new instance of SignUp.
- #method_missing(method_name, *args, &block) ⇒ Object
- #register(attrs) ⇒ Object
-
#username_taken? ⇒ Boolean
errors.added? DOES NOT WORK when the validation was given a custom message :).
Methods inherited from Base
#alert_message, #error_message, #errors, #success_message, #t
Constructor Details
#initialize ⇒ SignUp
Returns a new instance of SignUp.
7 8 9 |
# File 'lib/hello/business/registration/sign_up.rb', line 7 def initialize init_user end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
32 33 34 |
# File 'lib/hello/business/registration/sign_up.rb', line 32 def method_missing(method_name, *args, &block) user.send(method_name) end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'lib/hello/business/registration/sign_up.rb', line 5 def user @user end |
Instance Method Details
#email_taken? ⇒ Boolean
errors.added? DOES NOT WORK when the validation was given a custom message :)
23 24 25 |
# File 'lib/hello/business/registration/sign_up.rb', line 23 def email_taken? @email_credential && @email_credential.errors.added?(:email, :taken) end |
#register(attrs) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hello/business/registration/sign_up.rb', line 11 def register(attrs) init_user(attrs) user.save.tap do merge_errors_for(@email_credential) merge_errors_for(@password_credential) errors.delete(:email_credentials) errors.delete(:password_credentials) end end |
#username_taken? ⇒ Boolean
errors.added? DOES NOT WORK when the validation was given a custom message :)
28 29 30 |
# File 'lib/hello/business/registration/sign_up.rb', line 28 def username_taken? errors.added?(:username, :taken) end |