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(<<-MIGRATION) class #{model_name}FullTextSearch < ActiveRecord::Migration def self.up execute(<<-SQL.strip) #{up_migration(model_name)} SQL end def self.down execute(<<-SQL.strip) #{down_migration(model_name)} SQL end end MIGRATION 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 |