Class: BetterAuth::Sinatra::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/better_auth/sinatra/configuration.rb

Constant Summary collapse

AUTH_OPTION_NAMES =
%i[
  app_name
  base_url
  base_path
  secret
  database
  plugins
  trusted_origins
  rate_limit
  session
  account
  user
  verification
  advanced
  email_and_password
  password_hasher
  email_verification
  social_providers
  experimental
  secondary_storage
  database_hooks
  hooks
  on_api_error
  disabled_paths
  logger
].freeze

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



35
36
37
38
39
# File 'lib/better_auth/sinatra/configuration.rb', line 35

def initialize
  @base_path = BetterAuth::Configuration::DEFAULT_BASE_PATH
  @plugins = []
  @trusted_origins = []
end

Instance Method Details

#copyObject



51
52
53
54
55
56
57
58
# File 'lib/better_auth/sinatra/configuration.rb', line 51

def copy
  self.class.new.tap do |copy|
    AUTH_OPTION_NAMES.each do |name|
      value = public_send(name)
      copy.public_send("#{name}=", deep_dup(value))
    end
  end
end

#to_auth_optionsObject



41
42
43
44
45
46
47
48
49
# File 'lib/better_auth/sinatra/configuration.rb', line 41

def to_auth_options
  AUTH_OPTION_NAMES.each_with_object({}) do |name, options|
    value = public_send(name)
    next if value.nil?
    next if value.respond_to?(:empty?) && value.empty?

    options[name] = value
  end
end