Sha256: 43c7bd6fe465ea26b4dcb7a40b37499187cc2566f05119ed03c6b24490b6a662
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
require "rails/generators/active_record" module Ahoy module Generators module Messages class ActiverecordGenerator < Rails::Generators::Base include ActiveRecord::Generators::Migration source_root File.join(__dir__, "templates") class_option :unencrypted, type: :boolean def copy_migration migration_template "migration.rb", "db/migrate/create_ahoy_messages.rb", migration_version: migration_version end def copy_template if encrypted? template "model_encrypted.rb", "app/models/ahoy/message.rb" end end def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end def to_column if encrypted? "t.text :to_ciphertext\n t.string :to_bidx, index: true" else "t.string :to, index: true" end end def encrypted? !options[:unencrypted] end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems