Class: Clerk::ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/clerk/application_record.rb

Direct Known Subclasses

Account, Email, Role, SessionToken

Class Method Summary collapse

Class Method Details

.clerk_persistence_apiObject



13
14
15
16
17
18
# File 'lib/clerk/application_record.rb', line 13

def self.clerk_persistence_api
  @@clerk_persistence_api ||= ClerkActiveRecord::Api::Connection.new(
    (ENV["CLERK_API_PATH"] || "https://api.clerk.dev"),
    ENV["CLERK_KEY"]
  )
end

.clerk_persistence_pathObject



9
10
11
# File 'lib/clerk/application_record.rb', line 9

def self.clerk_persistence_path
  "/v1/#{table_name[0...-3]}"
end

.clerk_table_name(table_name) ⇒ Object



5
6
7
# File 'lib/clerk/application_record.rb', line 5

def self.clerk_table_name(table_name)
  "#{table_name}_01"
end

.transaction(options = {}, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/clerk/application_record.rb', line 20

def self.transaction(options = {}, &block)
  # were overriding all the methods that need transactions
  # these interfere with pgbouncer.  just yield the block
  yield
rescue ActiveRecord::Rollback
  # rollbacks are silently swallowed
end