Class: Texticle::FullTextIndexer
- Inherits:
-
Object
- Object
- Texticle::FullTextIndexer
- Defined in:
- lib/texticle/full_text_indexer.rb
Instance Method Summary collapse
Instance Method Details
#generate_migration(model_name) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/texticle/full_text_indexer.rb', line 2 def generate_migration(model_name) stream_output do |io| io.puts("class \#{model_name}FullTextSearch < ActiveRecord::Migration\ndef self.up\n execute(<<-SQL.strip)\n \#{up_migration(model_name)}\n SQL\nend\n\ndef self.down\n execute(<<-SQL.strip)\n \#{down_migration(model_name)}\n SQL\nend\nend\n") end end |
#stream_output(now = Time.now.utc, &block) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/texticle/full_text_indexer.rb', line 22 def stream_output(now = Time.now.utc, &block) if !@output_stream && defined?(Rails) File.open(migration_file_name(now), 'w', &block) else @output_stream ||= $stdout yield @output_stream end end |