Class: BetterAuth::Adapters::Base
- Inherits:
-
Object
- Object
- BetterAuth::Adapters::Base
- Defined in:
- lib/better_auth/adapters/base.rb
Constant Summary collapse
- TRANSACTION_CONTEXT_KEY =
:better_auth_adapter_transaction_context
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#atomic_transactions? ⇒ Boolean
The base yield preserves compatibility for non-atomic batch work.
-
#consume_one ⇒ Object
Atomically delete and return at most one matching row.
- #count ⇒ Object
- #create ⇒ Object
-
#create_if_absent(model:, data:, conflict_field: "id", force_allow_id: true) ⇒ Object
Atomically insert a row unless
conflict_fieldalready exists. - #delete ⇒ Object
- #delete_many ⇒ Object
- #find_many ⇒ Object
- #find_one ⇒ Object
-
#increment_one(model:, where:, increment:, set: nil, allow_server_managed: false) ⇒ Object
Atomically apply signed numeric deltas, with
whereacting as the selector and guard, and return the resulting row or nil on a miss. -
#initialize(options, transaction_context_key: nil) ⇒ Base
constructor
A new instance of Base.
- #transaction {|_self| ... } ⇒ Object
- #update ⇒ Object
- #update_many ⇒ Object
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(, transaction_context_key: nil) @options = @transaction_context_key = transaction_context_key || Object.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/better_auth/adapters/base.rb', line 6 def @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.
74 75 76 |
# File 'lib/better_auth/adapters/base.rb', line 74 def atomic_transactions? false end |
#consume_one ⇒ Object
Atomically delete and return at most one matching row. Concurrent consumers of the same row must produce exactly one non-nil result.
55 56 57 |
# File 'lib/better_auth/adapters/base.rb', line 55 def consume_one(**) raise NotImplementedError end |
#count ⇒ Object
49 50 51 |
# File 'lib/better_auth/adapters/base.rb', line 49 def count(**) raise NotImplementedError end |
#create ⇒ Object
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.
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 |
#delete ⇒ Object
41 42 43 |
# File 'lib/better_auth/adapters/base.rb', line 41 def delete(**) raise NotImplementedError end |
#delete_many ⇒ Object
45 46 47 |
# File 'lib/better_auth/adapters/base.rb', line 45 def delete_many(**) raise NotImplementedError end |
#find_many ⇒ Object
29 30 31 |
# File 'lib/better_auth/adapters/base.rb', line 29 def find_many(**) raise NotImplementedError end |
#find_one ⇒ Object
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.
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
68 69 70 |
# File 'lib/better_auth/adapters/base.rb', line 68 def transaction yield self end |
#update ⇒ Object
33 34 35 |
# File 'lib/better_auth/adapters/base.rb', line 33 def update(**) raise NotImplementedError end |
#update_many ⇒ Object
37 38 39 |
# File 'lib/better_auth/adapters/base.rb', line 37 def update_many(**) raise NotImplementedError end |