Class: BetterAuth::Adapters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/better_auth/adapters/base.rb

Direct Known Subclasses

Memory, SQL

Constant Summary collapse

TRANSACTION_CONTEXT_KEY =
:better_auth_adapter_transaction_context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, transaction_context_key: nil) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/better_auth/adapters/base.rb', line 10

def initialize(options, transaction_context_key: nil)
  @options = options
  @transaction_context_key = transaction_context_key || Object.new
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/better_auth/adapters/base.rb', line 6

def options
  @options
end

Instance Method Details

#atomic_transactions?Boolean

The base yield preserves compatibility for non-atomic batch work. It must never be used as proof that a check-then-act fallback is atomic.

Returns:

  • (Boolean)


74
75
76
# File 'lib/better_auth/adapters/base.rb', line 74

def atomic_transactions?
  false
end

#consume_oneObject

Atomically delete and return at most one matching row. Concurrent consumers of the same row must produce exactly one non-nil result.

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/better_auth/adapters/base.rb', line 55

def consume_one(**)
  raise NotImplementedError
end

#countObject

Raises:

  • (NotImplementedError)


49
50
51
# File 'lib/better_auth/adapters/base.rb', line 49

def count(**)
  raise NotImplementedError
end

#createObject

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/better_auth/adapters/base.rb', line 15

def create(**)
  raise NotImplementedError
end

#create_if_absent(model:, data:, conflict_field: "id", force_allow_id: true) ⇒ Object

Atomically insert a row unless conflict_field already exists. Adapter implementations must not emulate this with a check followed by create.

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/better_auth/adapters/base.rb', line 21

def create_if_absent(model:, data:, conflict_field: "id", force_allow_id: true)
  raise NotImplementedError
end

#deleteObject

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/better_auth/adapters/base.rb', line 41

def delete(**)
  raise NotImplementedError
end

#delete_manyObject

Raises:

  • (NotImplementedError)


45
46
47
# File 'lib/better_auth/adapters/base.rb', line 45

def delete_many(**)
  raise NotImplementedError
end

#find_manyObject

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/better_auth/adapters/base.rb', line 29

def find_many(**)
  raise NotImplementedError
end

#find_oneObject

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/better_auth/adapters/base.rb', line 25

def find_one(**)
  raise NotImplementedError
end

#increment_one(model:, where:, increment:, set: nil, allow_server_managed: false) ⇒ Object

Atomically apply signed numeric deltas, with where acting as the selector and guard, and return the resulting row or nil on a miss. Server-managed schema fields remain protected unless a trusted plugin or runtime caller opts in explicitly with allow_server_managed. Never derive privileged field names from user-controlled input.

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/better_auth/adapters/base.rb', line 64

def increment_one(model:, where:, increment:, set: nil, allow_server_managed: false)
  raise NotImplementedError
end

#transaction {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



68
69
70
# File 'lib/better_auth/adapters/base.rb', line 68

def transaction
  yield self
end

#updateObject

Raises:

  • (NotImplementedError)


33
34
35
# File 'lib/better_auth/adapters/base.rb', line 33

def update(**)
  raise NotImplementedError
end

#update_manyObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/better_auth/adapters/base.rb', line 37

def update_many(**)
  raise NotImplementedError
end