Module: ActiveVersion::Runtime
- Defined in:
- lib/active_version/runtime.rb
Defined Under Namespace
Classes: ActiveRecordAdapter, NullAdapter
Constant Summary
collapse
- REQUIRED_ADAPTER_METHODS =
%i[base_connection connection_for].freeze
Class Method Summary
collapse
Class Method Details
.active_record_connection_errors ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/active_version/runtime.rb', line 91
def active_record_connection_errors
return [] unless defined?(::ActiveRecord)
errors = [
::ActiveRecord::ConnectionNotEstablished,
::ActiveRecord::NoDatabaseError,
::ActiveRecord::StatementInvalid
]
errors << ::ActiveRecord::ConnectionNotDefined if defined?(::ActiveRecord::ConnectionNotDefined)
errors
end
|
.adapter ⇒ Object
77
78
79
|
# File 'lib/active_version/runtime.rb', line 77
def adapter
@adapter ||= default_adapter
end
|
.adapter=(runtime_adapter) ⇒ Object
81
82
83
84
85
|
# File 'lib/active_version/runtime.rb', line 81
def adapter=(runtime_adapter)
candidate = runtime_adapter || default_adapter
validate_adapter!(candidate)
@adapter = candidate
end
|
.required_adapter_methods ⇒ Object
.reset_adapter! ⇒ Object
87
88
89
|
# File 'lib/active_version/runtime.rb', line 87
def reset_adapter!
@adapter = default_adapter
end
|
.supports_current_transaction_id?(connection) ⇒ Boolean
109
110
111
112
113
|
# File 'lib/active_version/runtime.rb', line 109
def supports_current_transaction_id?(connection)
return adapter.supports_current_transaction_id?(connection) if adapter.respond_to?(:supports_current_transaction_id?)
postgresql_connection?(connection)
end
|
.supports_partition_catalog_checks?(connection) ⇒ Boolean
115
116
117
118
119
|
# File 'lib/active_version/runtime.rb', line 115
def supports_partition_catalog_checks?(connection)
return adapter.supports_partition_catalog_checks?(connection) if adapter.respond_to?(:supports_partition_catalog_checks?)
postgresql_connection?(connection)
end
|
.supports_transactional_context?(connection) ⇒ Boolean
103
104
105
106
107
|
# File 'lib/active_version/runtime.rb', line 103
def supports_transactional_context?(connection)
return adapter.supports_transactional_context?(connection) if adapter.respond_to?(:supports_transactional_context?)
postgresql_connection?(connection)
end
|
.valid_adapter?(runtime_adapter) ⇒ Boolean
73
74
75
|
# File 'lib/active_version/runtime.rb', line 73
def valid_adapter?(runtime_adapter)
missing_adapter_methods(runtime_adapter).empty?
end
|