Class: Rails::Contact::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/contact/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rails/contact/configuration.rb', line 12

def initialize
  @contact_class_name = "Rails::Contact::Contact"
  @elasticsearch_url = ENV.fetch("ELASTICSEARCH_URL", "http://127.0.0.1:9200")
  @search_backend = :elasticsearch
  @google_sync_enabled = false
  # When true with google_sync_enabled, the default index renders _google_sync_panel (host can override that partial).
  @google_sync_ui_on_index = true
  @google_max_contacts = 25_000
  @rolling_window_sort = :updated_at
  @google_client_id = ENV["GOOGLE_CLIENT_ID"]
  @google_client_secret = ENV["GOOGLE_CLIENT_SECRET"]
  @google_redirect_uri = ENV["GOOGLE_REDIRECT_URI"]
  @google_token_path = ENV.fetch("RAILS_CONTACT_GOOGLE_TOKEN_PATH", "tmp/rails_contact_google_token.json")
  # Optional: appended to familyName in Google People payloads only (not stored on Contact). Blank = disabled.
  @google_contact_family_name_suffix = ENV["RAILS_CONTACT_GOOGLE_CONTACT_FAMILY_NAME_SUFFIX"]&.presence
  @reset_index_on_boot = false
  @default_per_page = 25
  # When true (default), engine pages use the host app +layout+ named +application+ so
  # importmap/Turbo match the rest of the app. Engine CSS and nested-field JS are still
  # injected from gem templates so behavior does not depend on the engine layout asset tags.
  @inherit_host_layout = true
  # Declarative filters over Contact#metadata, keyed by the request param
  # name. The host app decides which metadata keys are filterable; the
  # engine permits the params, guards the SQL, and applies the filter
  # (database backend only). Example:
  #
  #   config.metadata_filters = {
  #     "tier"      => { key: "quality_tier", type: :values, allowed: %w[hot warm standard] },
  #     "min_pax"   => { key: "pax",          type: :min_integer },
  #     "min_score" => { key: "score",        type: :min_numeric },
  #     "vip"       => { key: "tags",         type: :tag, tag: "vip" }
  #   }
  #
  # :values      — multi-select; matches metadata->>key IN (...). Optional
  #                :allowed whitelist discards anything else.
  # :min_integer — numeric floor over an integer-ish metadata string;
  #                non-numeric stored values are filtered out, never cast.
  # :min_numeric — same, but accepts decimals.
  # :tag         — checkbox; matches when the metadata key (a JSON array)
  #                contains :tag. Param value "1" switches it on.
  # :exclude     — hides rows whose key equals :value. Add default: :on
  #                to apply it even when the param is absent; an
  #                explicit "0" shows everything. Rows missing the key
  #                always pass.
  @metadata_filters = {}
  # Sort options over numeric metadata, keyed by the ?sort= param value:
  #
  #   config.metadata_sorts = { "score" => { key: "score" } }
  #
  # Sorts descending, non-numeric values last, ties broken by recency.
  # Ignored while a free-text q search is active: the search branch runs
  # SELECT DISTINCT and PostgreSQL rejects ordering by an expression that
  # is not in the select list, so search results keep recency order.
  @metadata_sorts = {}
end

Instance Attribute Details

#contact_class_nameObject

Returns the value of attribute contact_class_name.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def contact_class_name
  @contact_class_name
end

#default_per_pageObject

Returns the value of attribute default_per_page.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def default_per_page
  @default_per_page
end

#elasticsearch_urlObject

Returns the value of attribute elasticsearch_url.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def elasticsearch_url
  @elasticsearch_url
end

#google_client_idObject

Returns the value of attribute google_client_id.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_client_id
  @google_client_id
end

#google_client_secretObject

Returns the value of attribute google_client_secret.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_client_secret
  @google_client_secret
end

#google_contact_family_name_suffixObject

Returns the value of attribute google_contact_family_name_suffix.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_contact_family_name_suffix
  @google_contact_family_name_suffix
end

#google_max_contactsObject

Returns the value of attribute google_max_contacts.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_max_contacts
  @google_max_contacts
end

#google_redirect_uriObject

Returns the value of attribute google_redirect_uri.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_redirect_uri
  @google_redirect_uri
end

#google_sync_enabledObject

Returns the value of attribute google_sync_enabled.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_sync_enabled
  @google_sync_enabled
end

#google_sync_ui_on_indexObject

Returns the value of attribute google_sync_ui_on_index.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_sync_ui_on_index
  @google_sync_ui_on_index
end

#google_token_pathObject

Returns the value of attribute google_token_path.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def google_token_path
  @google_token_path
end

#inherit_host_layoutObject

Returns the value of attribute inherit_host_layout.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def inherit_host_layout
  @inherit_host_layout
end

#metadata_filtersObject

Returns the value of attribute metadata_filters.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def 
  @metadata_filters
end

#metadata_sortsObject

Returns the value of attribute metadata_sorts.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def 
  @metadata_sorts
end

#reset_index_on_bootObject

Returns the value of attribute reset_index_on_boot.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def reset_index_on_boot
  @reset_index_on_boot
end

#rolling_window_sortObject

Returns the value of attribute rolling_window_sort.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def rolling_window_sort
  @rolling_window_sort
end

#search_backendObject

Returns the value of attribute search_backend.



4
5
6
# File 'lib/rails/contact/configuration.rb', line 4

def search_backend
  @search_backend
end