Class: Nyauth::ConfirmationRequest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/services/nyauth/confirmation_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_params = {}) ⇒ ConfirmationRequest

Returns a new instance of ConfirmationRequest.



6
7
8
# File 'app/services/nyauth/confirmation_request.rb', line 6

def initialize(service_params = {})
  @email = service_params[:email]
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'app/services/nyauth/confirmation_request.rb', line 4

def client
  @client
end

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'app/services/nyauth/confirmation_request.rb', line 4

def email
  @email
end

Instance Method Details

#save(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/services/nyauth/confirmation_request.rb', line 10

def save(options = {})
  options.reverse_merge!(as: :user)
  klass = options[:as].to_s.classify.constantize
  @client = klass.with_given_email(@email).last!
  @client.request_confirmation
rescue
  errors.add(:base, :invalid_email)
end