Class: Ahoy::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ahoy/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_templatesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/ahoy/install_generator.rb', line 8

def copy_templates
  activerecord = defined?(ActiveRecord)
  mongoid = defined?(Mongoid)

  selection =
    if activerecord && mongoid
      puts <<-MSG

Which data store would you like to use?
 1. ActiveRecord (default)
 2. Mongoid
 3. Neither
      MSG

      ask(">")
    elsif activerecord
      "1"
    elsif mongoid
      "2"
    else
      "3"
    end

  case selection
  when "", "1"
    invoke "ahoy:activerecord"
  when "2"
    invoke "ahoy:mongoid"
  when "3"
    invoke "ahoy:base"
  else
    abort "Error: must enter a number [1-3]"
  end
end