Sha256: 2ba2bac3847686c6bf126b85090436038bb69dba3a54224c2b6f949586bbfcf3

Contents?: true

Size: 470 Bytes

Versions: 2

Compression:

Stored size: 470 Bytes

Contents

module Nyauth
  class ConfirmationRequest
    include ActiveModel::Model
    attr_reader :email, :client

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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nyauth-0.7.2 app/services/nyauth/confirmation_request.rb
nyauth-0.7.1 app/services/nyauth/confirmation_request.rb