Class: Chimpmunk::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#installObject



5
6
7
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
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/generators/chimpmunk/install_generator.rb', line 5

def install
  rails_admin_initializer = "#{Rails.root}/config/initializers/rails_admin.rb"
  if File.exist?(rails_admin_initializer)
    inject_into_file rails_admin_initializer, after: 'RailsAdmin.config do |config|' do <<-'TEMPLATE'

  # include all custom actions from lib/rails_admin
  Dir["#{Rails.root}/lib/rails_admin/*.rb"].each {|file| require file }

  # include all existing models and Chimpmunk models
  config.included_models = Dir.glob("#{Rails.root}/app/models/*.rb").map{|x| File.basename(x, ".rb").camelize} + 
['Chimpmunk::EmailCampaign', 'Chimpmunk::EmailList', 'Chimpmunk::EmailListGroup', 'Chimpmunk::EmailListGrouping', 
  'Chimpmunk::EmailSubscriber', 'Chimpmunk::EmailTemplate', 'Chimpmunk::EmailCampaignHeader', 'Chimpmunk::EmailCampaignText', 'Chimpmunk::EmailCampaignImage']

      TEMPLATE
    end

    inject_into_file rails_admin_initializer, after: 'config.actions do' do <<-'TEMPLATE'

refresh_email_templates do
  only 'Chimpmunk::EmailTemplate'
end

refresh_email_campaigns do
  only 'Chimpmunk::EmailCampaign'
end

refresh_email_campaign_stats do
  only 'Chimpmunk::EmailCampaign'
end

send_email_campaign do
  only 'Chimpmunk::EmailCampaign'
end

schedule_email_campaign do
  only 'Chimpmunk::EmailCampaign'
end

un_schedule_email_campaign do
  only 'Chimpmunk::EmailCampaign'
end

refresh_email_lists do
  only 'Chimpmunk::EmailList'
end

    TEMPLATE
    end
  end
end