class ActsAsContentHighlightable::Generators::InstallGenerator
Public Instance Methods
copy_migration()
click to toggle source
# File lib/generators/acts_as_content_highlightable/install_generator.rb, line 25 def copy_migration @database = options["database"] || detect_database unless @database.in?([nil, "postgresql", "postgresql-jsonb", "mysql", "sqlite"]) raise Thor::Error, "Unknown database option" end migration_template "active_record_content_highlights_migration.rb", "db/migrate/create_content_highlights.rb", migration_version: migration_version end
detect_database()
click to toggle source
# File lib/generators/acts_as_content_highlightable/install_generator.rb, line 37 def detect_database postgresql_version = ActiveRecord::Base.connection.send(:postgresql_version) rescue 0 if postgresql_version >= 90400 "postgresql-jsonb" elsif postgresql_version >= 90200 "postgresql" end end
generate_model()
click to toggle source
# File lib/generators/acts_as_content_highlightable/install_generator.rb, line 33 def generate_model template "active_record_content_highlight_model.rb", "app/models/content_highlight.rb" end
migration_version()
click to toggle source
# File lib/generators/acts_as_content_highlightable/install_generator.rb, line 46 def migration_version if ActiveRecord::VERSION::MAJOR >= 5 "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end end