Module: LlmCostTracker::Ledger::Schema::Adapter
- Defined in:
- lib/llm_cost_tracker/ledger/schema/adapter.rb
Constant Summary collapse
- MYSQL_ADAPTERS =
%w[ ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter ActiveRecord::ConnectionAdapters::Mysql2Adapter ActiveRecord::ConnectionAdapters::TrilogyAdapter ].freeze
- POSTGRESQL_ADAPTERS =
%w[ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter ].freeze
- MYSQL_PATTERN =
/mysql|trilogy|mariadb/i- POSTGRESQL_PATTERN =
/postgres/i
Class Method Summary collapse
Class Method Details
.ensure_supported!(value) ⇒ Object
29 30 31 32 33 |
# File 'lib/llm_cost_tracker/ledger/schema/adapter.rb', line 29 def ensure_supported!(value) return if mysql?(value) || postgresql?(value) raise Error, "Unsupported database adapter: #{adapter_name(value)}. Use PostgreSQL or MySQL." end |
.mysql?(value) ⇒ Boolean
21 22 23 |
# File 'lib/llm_cost_tracker/ledger/schema/adapter.rb', line 21 def mysql?(value) adapter_instance?(value, MYSQL_ADAPTERS) || adapter_name(value).match?(MYSQL_PATTERN) end |
.postgresql?(value) ⇒ Boolean
25 26 27 |
# File 'lib/llm_cost_tracker/ledger/schema/adapter.rb', line 25 def postgresql?(value) adapter_instance?(value, POSTGRESQL_ADAPTERS) || adapter_name(value).match?(POSTGRESQL_PATTERN) end |