Class: Nyauth::Registration
- Inherits:
-
Object
- Object
- Nyauth::Registration
- Includes:
- ActiveModel::Model
- Defined in:
- app/services/nyauth/registration.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#password_confirmation ⇒ Object
readonly
Returns the value of attribute password_confirmation.
Instance Method Summary collapse
-
#initialize(service_params = {}) ⇒ Registration
constructor
A new instance of Registration.
- #save(options = {}) ⇒ Object
Constructor Details
#initialize(service_params = {}) ⇒ Registration
Returns a new instance of Registration.
6 7 8 9 10 |
# File 'app/services/nyauth/registration.rb', line 6 def initialize(service_params = {}) @email = service_params[:email] @password = service_params[:password] @password_confirmation = service_params[:password_confirmation] end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/nyauth/registration.rb', line 4 def client @client end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
4 5 6 |
# File 'app/services/nyauth/registration.rb', line 4 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'app/services/nyauth/registration.rb', line 4 def password @password end |
#password_confirmation ⇒ Object (readonly)
Returns the value of attribute password_confirmation.
4 5 6 |
# File 'app/services/nyauth/registration.rb', line 4 def password_confirmation @password_confirmation end |
Instance Method Details
#save(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/services/nyauth/registration.rb', line 12 def save( = {}) .reverse_merge!(as: :user) klass = [:as].to_s.classify.constantize @client = klass.create(email: @email, password: @password, password_confirmation: @password_confirmation) @errors = @client.errors @client.valid? end |