Class: NeonPostgres::Database
- Inherits:
-
Object
- Object
- NeonPostgres::Database
- Defined in:
- lib/neon_postgres/database.rb
Class Method Summary collapse
- .admin_connection(user_id:) ⇒ Object
- .anonymous_connection ⇒ Object
- .connection ⇒ Object
- .from_connection ⇒ Object
- .lawyer_connection(user_id:) ⇒ Object
- .portal_connection(user_id:) ⇒ Object
- .to_connection ⇒ Object
Class Method Details
.admin_connection(user_id:) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/neon_postgres/database.rb', line 48 def self.admin_connection(user_id:) @_admin_connection ||= Sequel.connect( ENV.fetch("DATABASE_URL") { "postgres://postgres:password@localhost:5432/neon_law" }, connect_sqls: [ "SET role = 'admin';", "SET \"person.id\" = '#{user_id}';" ] ) end |
.anonymous_connection ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/neon_postgres/database.rb', line 13 def self.anonymous_connection @_anonymous_connection ||= Sequel.connect( ENV.fetch("DATABASE_URL") { "postgres://postgres:password@localhost:5432/neon_law" }, connect_sqls: [ "SET role = 'anonymous';" ] ) end |
.connection ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/neon_postgres/database.rb', line 5 def self.connection @_connection ||= Sequel.connect( ENV.fetch("DATABASE_URL") { "postgres://postgres:password@localhost:5432/neon_law" } ) end |
.from_connection ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/neon_postgres/database.rb', line 60 def self.from_connection @_from_connection ||= Sequel.connect( ENV.fetch("FROM_DATABASE_URL") { "postgres://postgres:password@localhost:5432/production" } ) end |
.lawyer_connection(user_id:) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/neon_postgres/database.rb', line 36 def self.lawyer_connection(user_id:) @_lawyer_connection ||= Sequel.connect( ENV.fetch("DATABASE_URL") { "postgres://postgres:password@localhost:5432/neon_law" }, connect_sqls: [ "SET role = 'lawyer';", "SET \"person.id\" = '#{user_id}';" ] ) end |
.portal_connection(user_id:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/neon_postgres/database.rb', line 24 def self.portal_connection(user_id:) @_portal_connection ||= Sequel.connect( ENV.fetch("DATABASE_URL") { "postgres://postgres:password@localhost:5432/neon_law" }, connect_sqls: [ "SET role = 'portal';", "SET \"person.id\" = '#{user_id}';" ] ) end |
.to_connection ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/neon_postgres/database.rb', line 68 def self.to_connection @_to_connection ||= Sequel.connect( ENV.fetch("TO_DATABASE_URL") { "postgres://postgres:password@localhost:5432/staging" } ) end |