Class: Supabase::ClientOptions
- Inherits:
-
Object
- Object
- Supabase::ClientOptions
- Defined in:
- lib/supabase/client_options.rb
Overview
Structured options passed to create_client / Client. Mirrors supabase-py’s ‘SyncClientOptions` / `AsyncClientOptions`. The Ruby port uses one class because the sync/async split is decided at runtime via the `async:` flag on the umbrella client.
opts = Supabase::ClientOptions.new(
schema: "public",
headers: { "X-Tenant" => "acme" },
auto_refresh_token: true,
persist_session: true,
postgrest_client_timeout: 30,
storage_client_timeout: 20,
function_client_timeout: 10,
flow_type: "pkce"
)
Supabase.create_client(supabase_url: url, supabase_key: key, options: opts)
Constant Summary collapse
- DEFAULT_POSTGREST_TIMEOUT =
120- DEFAULT_STORAGE_TIMEOUT =
20- DEFAULT_FUNCTIONS_TIMEOUT =
60- DEFAULT_HEADERS =
{ "X-Client-Info" => "supabase-rb/#{Supabase::VERSION}" }.freeze
Instance Attribute Summary collapse
-
#auto_refresh_token ⇒ Object
Returns the value of attribute auto_refresh_token.
-
#flow_type ⇒ Object
Returns the value of attribute flow_type.
-
#function_client_timeout ⇒ Object
Returns the value of attribute function_client_timeout.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
-
#persist_session ⇒ Object
Returns the value of attribute persist_session.
-
#postgrest_client_timeout ⇒ Object
Returns the value of attribute postgrest_client_timeout.
-
#realtime ⇒ Object
Returns the value of attribute realtime.
-
#schema ⇒ Object
Returns the value of attribute schema.
-
#storage ⇒ Object
Returns the value of attribute storage.
-
#storage_client_timeout ⇒ Object
Returns the value of attribute storage_client_timeout.
Instance Method Summary collapse
-
#initialize(schema: "public", headers: nil, auto_refresh_token: true, persist_session: true, realtime: nil, postgrest_client_timeout: DEFAULT_POSTGREST_TIMEOUT, storage_client_timeout: DEFAULT_STORAGE_TIMEOUT, function_client_timeout: DEFAULT_FUNCTIONS_TIMEOUT, flow_type: "pkce", storage: nil, http_client: nil) ⇒ ClientOptions
constructor
A new instance of ClientOptions.
-
#replace(**overrides) ⇒ Object
Returns a new ClientOptions with the given fields overridden.
- #to_h ⇒ Object
Constructor Details
#initialize(schema: "public", headers: nil, auto_refresh_token: true, persist_session: true, realtime: nil, postgrest_client_timeout: DEFAULT_POSTGREST_TIMEOUT, storage_client_timeout: DEFAULT_STORAGE_TIMEOUT, function_client_timeout: DEFAULT_FUNCTIONS_TIMEOUT, flow_type: "pkce", storage: nil, http_client: nil) ⇒ ClientOptions
Returns a new instance of ClientOptions.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/supabase/client_options.rb', line 34 def initialize(schema: "public", headers: nil, auto_refresh_token: true, persist_session: true, realtime: nil, postgrest_client_timeout: DEFAULT_POSTGREST_TIMEOUT, storage_client_timeout: DEFAULT_STORAGE_TIMEOUT, function_client_timeout: DEFAULT_FUNCTIONS_TIMEOUT, flow_type: "pkce", storage: nil, http_client: nil) @schema = schema @headers = DEFAULT_HEADERS.merge(headers || {}) @auto_refresh_token = auto_refresh_token @persist_session = persist_session @realtime = realtime @postgrest_client_timeout = postgrest_client_timeout @storage_client_timeout = storage_client_timeout @function_client_timeout = function_client_timeout @flow_type = flow_type @storage = storage @http_client = http_client end |
Instance Attribute Details
#auto_refresh_token ⇒ Object
Returns the value of attribute auto_refresh_token.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def auto_refresh_token @auto_refresh_token end |
#flow_type ⇒ Object
Returns the value of attribute flow_type.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def flow_type @flow_type end |
#function_client_timeout ⇒ Object
Returns the value of attribute function_client_timeout.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def function_client_timeout @function_client_timeout end |
#headers ⇒ Object
Returns the value of attribute headers.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def headers @headers end |
#http_client ⇒ Object
Returns the value of attribute http_client.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def http_client @http_client end |
#persist_session ⇒ Object
Returns the value of attribute persist_session.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def persist_session @persist_session end |
#postgrest_client_timeout ⇒ Object
Returns the value of attribute postgrest_client_timeout.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def postgrest_client_timeout @postgrest_client_timeout end |
#realtime ⇒ Object
Returns the value of attribute realtime.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def realtime @realtime end |
#schema ⇒ Object
Returns the value of attribute schema.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def schema @schema end |
#storage ⇒ Object
Returns the value of attribute storage.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def storage @storage end |
#storage_client_timeout ⇒ Object
Returns the value of attribute storage_client_timeout.
30 31 32 |
# File 'lib/supabase/client_options.rb', line 30 def storage_client_timeout @storage_client_timeout end |
Instance Method Details
#replace(**overrides) ⇒ Object
Returns a new ClientOptions with the given fields overridden. Mirrors supabase-py’s ‘replace()` — handy because dataclasses there are frozen at the field-level and we want the same “build then derive” ergonomics.
61 62 63 64 |
# File 'lib/supabase/client_options.rb', line 61 def replace(**overrides) attrs = to_h.merge(overrides) self.class.new(**attrs) end |
#to_h ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/supabase/client_options.rb', line 66 def to_h { schema: @schema, headers: @headers, auto_refresh_token: @auto_refresh_token, persist_session: @persist_session, realtime: @realtime, postgrest_client_timeout: @postgrest_client_timeout, storage_client_timeout: @storage_client_timeout, function_client_timeout: @function_client_timeout, flow_type: @flow_type, storage: @storage, http_client: @http_client } end |