module Rodauth::Model::ActiveRecord

def define_methods(model)

def define_methods(model)
  rodauth = @auth_class.allocate.freeze
  attr_reader :password
  define_method(:password=) do |password|
    @password = password
    password_hash = rodauth.password_hash(password) if password
    set_password_hash(password_hash)
  end
  define_method(:set_password_hash) do |password_hash|
    if rodauth.account_password_hash_column
      public_send(:"#{rodauth.account_password_hash_column}=", password_hash)
    else
      if password_hash
        record = self.password_hash || build_password_hash
        record.public_send(:"#{rodauth.password_hash_column}=", password_hash)
      else
        self.password_hash&.mark_for_destruction
      end
    end
  end
end