Class: PoBoxGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/po_box/po_box_generator.rb

Instance Method Summary collapse

Instance Method Details

#append_to_manifestObject



28
29
30
31
32
# File 'lib/generators/po_box/po_box_generator.rb', line 28

def append_to_manifest
  append_to_file "app/assets/config/manifest.js" do
    "//= link po_box/application.css\n"
  end
end

#include_concernsObject



12
13
14
15
16
17
18
# File 'lib/generators/po_box/po_box_generator.rb', line 12

def include_concerns
  inject_into_file "app/models/#{name.tableize.singularize}.rb", after: "class #{name.camelize} < ApplicationRecord\n" do
    <<-RUBY
      include PoBox::Emailable
    RUBY
  end
end

#mount_engineObject



8
9
10
# File 'lib/generators/po_box/po_box_generator.rb', line 8

def mount_engine
  route "mount PoBox::Engine, at: \"/po_box\""
end

#setup_inboxObject



20
21
22
23
24
25
26
# File 'lib/generators/po_box/po_box_generator.rb', line 20

def setup_inbox
  inject_into_file "app/mailboxes/application_mailbox.rb", after: "class ApplicationMailbox < ActionMailbox::Base\n" do
    <<-RUBY
      routing all: "po_box/inbox"
    RUBY
  end
end

#setup_initializerObject



4
5
6
# File 'lib/generators/po_box/po_box_generator.rb', line 4

def setup_initializer
  create_file "config/initializers/po_box.rb", "PoBox.emailable_class = \"#{name.camelize}\""
end