Class: Mistri::Generators::InstallGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/mistri/install/install_generator.rb

Overview

bin/rails generate mistri:install AgentEntry

Creates the session-entry model, named by the host application, and its migration, ready for Mistri::Stores::ActiveRecord.

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



24
25
26
27
# File 'lib/generators/mistri/install/install_generator.rb', line 24

def create_migration_file
  migration_template "migration.rb.tt",
                     File.join(db_migrate_path, "create_#{table_name}.rb")
end

#create_modelObject



20
21
22
# File 'lib/generators/mistri/install/install_generator.rb', line 20

def create_model
  template "model.rb.tt", File.join("app/models", class_path, "#{file_name}.rb")
end

#show_wiringObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/mistri/install/install_generator.rb', line 29

def show_wiring
  say <<~NOTE

    Wire the store with your model:

      store = Mistri::Stores::ActiveRecord.new(#{class_name})
      session = Mistri::Session.new(store: store)

    (require "mistri/stores/active_record" where you build it.)

  NOTE
end