2016-11-15 15:56:29 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-17 15:56:23 +00:00
|
|
|
class ApplicationRecord < ActiveRecord::Base
|
2024-11-15 15:37:30 +00:00
|
|
|
primary_abstract_class
|
2019-08-05 17:54:29 +00:00
|
|
|
|
2018-03-26 12:02:10 +00:00
|
|
|
include Remotable
|
2019-08-05 17:54:29 +00:00
|
|
|
|
2023-09-22 14:01:59 +00:00
|
|
|
connects_to database: { writing: :primary, reading: :replica } if DatabaseHelper.replica_enabled?
|
2023-07-17 06:26:52 +00:00
|
|
|
|
2019-09-30 23:19:11 +00:00
|
|
|
class << self
|
|
|
|
def update_index(_type_name, *_args, &_block)
|
|
|
|
super if Chewy.enabled?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-05 17:54:29 +00:00
|
|
|
def boolean_with_default(key, default_value)
|
|
|
|
value = attributes[key]
|
|
|
|
|
|
|
|
if value.nil?
|
|
|
|
default_value
|
|
|
|
else
|
|
|
|
value
|
|
|
|
end
|
|
|
|
end
|
2024-04-29 09:45:58 +00:00
|
|
|
|
|
|
|
# Prevent implicit serialization in ActiveModel::Serializer or other code paths.
|
|
|
|
# This is a hardening step to avoid accidental leaking of attributes.
|
|
|
|
def as_json
|
|
|
|
raise NotImplementedError
|
|
|
|
end
|
2016-08-17 15:56:23 +00:00
|
|
|
end
|