-
-
Notifications
You must be signed in to change notification settings - Fork 15
Configuring
Some resources may have extra configurations that can be set in your application.rb
as following:
# application.rb
Torque::PostgreSQL.configure do |c|
c.enum.base_method = :pg_enum
end
These are the keys available to configure general features:
eager_load
Set if any information that requires querying and searching or collecting information should be eager loaded. This automatically changes when rails same configuration is set to true.
Default value: false
use_extended_defaults
This allows default values to have extended values like arrays and casted values. Extended defaults is still experimental, so enable and test it before using it in production.
Default value: false
irregular_models
Set a list of irregular model names when associated with table names. It uses the 'table_name' => 'model_name'
format. This is widely used for inheritance because record types need to be associated with a model class.
Default value: {}
These are the keys available to configure schemas features:
schemas.blacklist
Defines a list of LIKE-based schemas to not consider for a multiple schema database. This is also available on config/database.yml
as schemas
and nested to it, blacklist
.
Default value: ['information_schema ', 'pg_%']
schemas.whitelist
Defines a list of LIKE-based schemas to consider for a multiple schema database. This is also available on config/database.yml
as schemas
and nested to it, whitelist
.
Default value: ['public']
These are the keys available to configure associations features:
associations.belongs_to_many_required_by_default
Define if belongs_to_many
associations are marked as required by default. false
means that no validation will be performed.
Default value: false
These are the keys available to configure Auxiliary statements features:
auxiliary_statement.send_arguments_key
Define the key that is used on auxiliary statements to send extra arguments to format string or send on a proc.
Default value: :args
auxiliary_statement.exposed_class
Estipulate a class name (which may contain namespace) that exposes the auxiliary statement in order to perform detached CTEs.
Default value: 'TorqueCTE'
auxiliary_statement.exposed_recursive_class
Estipulate a class name (which may contain namespace) that exposes the recursive auxiliary statement in order to perform detached CTEs.
Default value: 'TorqueRecursiveCTE'
These are the keys available to configure Enum features:
enum.base_method
The name of the method to be used on any ActiveRecord::Base to initialize model-based enum features.
Default value: :torque_enum
enum.set_method
The name of the method to be used on any ActiveRecord::Base to initialize model-based enum set features.
Default value: :torque_enum_set
enum.save_on_bang
Indicates if bang methods like 'disabled!' should update the record on database or not.
Default value: true
enum.raise_conflicting
Indicates if it should raise errors when a generated method would conflict with an existing one.
Default value: false
enum.namespace
Specify the namespace of each enum-type of value, such as ::Enum::Roles
.
Default value: ::Enum
enum.i18n_scopes
Specify the scopes for I18n translations.
Default value:
[ 'activerecord.attributes.%{model}.%{attr}.%{value}',
'activerecord.attributes.%{attr}.%{value}',
'activerecord.enums.%{type}.%{value}',
'enum.%{type}.%{value}',
'enum.%{value}' ]
enum.i18n_type_scope
Specify the scopes for I18n translations, detached from model.
Default value: # Same list as before but without items that have ${attr} or %{model}
These are the keys available to configure geometries features:
geometry.point_class
Define the class that will be handling Point data types after decoding it. Any class provided here must respond to 'x', and 'y'.
Default value: ActiveRecord::Point
geometry.point_class
Define the class that will be handling Circle data types after decoding it. Any class provided here must respond to 'x', 'y', and 'r'.
Default value: nil # Which will define an internal Circle class
geometry.point_class
Define the class that will be handling Box data types after decoding it. Any class provided here must respond to 'x1', 'y1', 'x2', and 'y2'.
Default value: nil # Which will define an internal Box class
geometry.point_class
Define the class that will be handling Line data types after decoding it. Any class provided here must respond to 'a', 'b', and 'c'.
Default value: nil # Which will define an internal Line class
geometry.point_class
Define the class that will be handling Segment data types after decoding it. Any class provided here must respond to 'x1', 'y1', 'x2', and 'y2'.
Default value: nil # Which will define an internal Segment class
These are the keys available to configure Inheritance features:
inheritance.inverse_lookup
Define the lookup of models from their given name to be inverted, which means that they are going to form the last namespaced one to the most namespaced one. If you prefer User::Role
instead of UserRole
as model name, set this to false
to improve performance.
Default value: true
inheritance.record_class_column_name
Determines the name of the column used to collect the table of each record. When the table has inheritance tables, this column will return the name of the table that actually holds the record.
Default value: :_record_class
inheritance.auto_cast_column_name
Determines the name of the column used when identifying that the loaded records should be casted to its correctly model. This will be TRUE for the records mentioned on cast_records
.
Default value: :_auto_cast
These are the keys available to configure Period features:
period.base_method
The name of the method to be used on any ActiveRecord::Base to initialize model-based period features.
Default value: :period_for
period.method_names
Define the list of methods that will be created by default while setting up a new period field. Note that %s
will be replaced by the name of the filter.
Default value:
{ current_on: '%s_on',
current: 'current_%s',
not_current: 'not_current_%s',
containing: '%s_containing',
not_containing: '%s_not_containing',
overlapping: '%s_overlapping',
not_overlapping: '%s_not_overlapping',
starting_after: '%s_starting_after',
starting_before: '%s_starting_before',
finishing_after: '%s_finishing_after',
finishing_before: '%s_finishing_before',
real_containing: '%s_real_containing',
real_overlapping: '%s_real_overlapping',
real_starting_after: '%s_real_starting_after',
real_starting_before: '%s_real_starting_before',
real_finishing_after: '%s_real_finishing_after',
real_finishing_before: '%s_real_finishing_before',
containing_date: '%s_containing_date',
not_containing_date: '%s_not_containing_date',
overlapping_date: '%s_overlapping_date',
not_overlapping_date: '%s_not_overlapping_date',
real_containing_date: '%s_real_containing_date',
real_overlapping_date: '%s_real_overlapping_date',
current?: 'current_%s?,
current_on?: 'current_%s_on?,
start: '%s_start',
finish: '%s_finish',
real: 'real_%s',
real_start: '%s_real_start',
real_finish: '%s_real_finish', }
period.direct_method_names
If the period is marked as direct access, without the field name, then these method names will replace the default ones.
Default value:
{ current_on: 'happening_in',
containing: 'during',
not_containing: 'not_during',
real_containing: 'real_during',
containing_date: 'during_date',
not_containing_date: 'not_during_date',
current_on?: 'happening_in?',
start: 'start_at',
finish: 'finish_at',
real: 'real_time',
real_start: 'real_start_at',
real_finish: 'real_finish_at', }
Can't find what you're looking for? Add an issue to the issue tracker.