Class: RubyLLM::Generators::LegacyContentSQL

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/ruby_llm/upgrade/legacy_content_sql.rb

Overview

:nodoc: all

Constant Summary collapse

SPACE =
[9, 10, 11, 12, 13, 32, 133, 160, 5760, *8192..8202, 8232, 8233, 8239, 8287, 12_288].pack('U*').freeze

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ LegacyContentSQL

Returns a new instance of LegacyContentSQL.



8
9
10
# File 'lib/generators/ruby_llm/upgrade/legacy_content_sql.rb', line 8

def initialize(connection)
  @connection = connection
end

Instance Method Details

#render(content:, raw:) ⇒ Object



12
13
14
15
16
# File 'lib/generators/ruby_llm/upgrade/legacy_content_sql.rb', line 12

def render(content:, raw:)
  normalized, rendered, nonblank = expressions(raw)
  present = "#{normalized} NOT IN ('null', 'false', '[]', '{}') AND #{nonblank}"
  "CASE WHEN #{present} THEN #{rendered} ELSE #{content} END"
end