diff --git a/lib/good_job.rb b/lib/good_job.rb index 8858e51de..a7304e346 100644 --- a/lib/good_job.rb +++ b/lib/good_job.rb @@ -17,7 +17,13 @@ # # +GoodJob+ is the top-level namespace and exposes configuration attributes. module GoodJob - # TODO: explain me + # @!attribute [rw] active_record_parent_class + # @!scope class + # The ActiveRecord parent class inherited by +GoodJob::Job+ (default: +ActiveRecord::Base+). + # Use this when using multiple databases or other custom ActiveRecord configuration. + # @return [ActiveRecord::Base] + # @example Change the base class: + # GoodJob.active_record_parent_class = "CustomApplicationRecord" mattr_accessor :active_record_parent_class, default: "ActiveRecord::Base" # @!attribute [rw] logger diff --git a/lib/good_job/lockable.rb b/lib/good_job/lockable.rb index 28b270d2b..a5471cd94 100644 --- a/lib/good_job/lockable.rb +++ b/lib/good_job/lockable.rb @@ -143,7 +143,7 @@ def with_advisory_lock def supports_cte_materialization_specifiers? return @_supports_cte_materialization_specifiers if defined?(@_supports_cte_materialization_specifiers) - @_supports_cte_materialization_specifiers = Job.connection.postgresql_version >= 120000 + @_supports_cte_materialization_specifiers = connection.postgresql_version >= 120000 end end @@ -158,7 +158,7 @@ def advisory_lock WHERE pg_try_advisory_lock(('x'||substr(md5($1 || $2::text), 1, 16))::bit(64)::bigint) SQL binds = [[nil, self.class.table_name], [nil, send(self.class.primary_key)]] - Job.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Advisory Lock', binds).any? + self.class.connection.exec_query(pg_or_jdbc_query(query), 'GoodJob::Lockable Advisory Lock', binds).any? end # Releases an advisory lock on this record if it is locked by this database