Class: Hayfork::Generators::HaystackGenerator

Inherits:
ActiveRecord::Generators::Base
  • Object
show all
Defined in:
lib/generators/hayfork/haystack_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_migrationObject



18
19
20
# File 'lib/generators/hayfork/haystack_generator.rb', line 18

def copy_migration
  migration_template "migrations/create.rb", "#{db_migrate_path}/create_#{table_name}.rb", migration_version: migration_version
end

#copy_modelObject



14
15
16
# File 'lib/generators/hayfork/haystack_generator.rb', line 14

def copy_model
  template "model.rb", "app/models/#{file_name}.rb"
end

#copy_query_modelsObject



26
27
28
29
30
31
# File 'lib/generators/hayfork/haystack_generator.rb', line 26

def copy_query_models
  template "query.rb", "app/models/query.rb"
  template "query/exact_phrase.rb", "app/models/query/exact_phrase.rb"
  template "query/object.rb", "app/models/query/object.rb"
  template "query/parser.rb", "app/models/query/parser.rb"
end

#copy_triggersObject



22
23
24
# File 'lib/generators/hayfork/haystack_generator.rb', line 22

def copy_triggers
  template "triggers.rb", "lib/#{file_name}_triggers.rb"
end

#migration_versionObject



38
39
40
41
# File 'lib/generators/hayfork/haystack_generator.rb', line 38

def migration_version
  return unless Rails::VERSION::MAJOR >= 5
  "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end

#table_nameObject



33
34
35
36
# File 'lib/generators/hayfork/haystack_generator.rb', line 33

def table_name
  return "haystack" if class_name == "Haystack"
  super
end