Sha256: a4372a254722fa4e3de7bbe4797f2f092e6e92d3e69e26a6f9eda7aab6d71807

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

class PoBoxGenerator < Rails::Generators::NamedBase
  source_root File.expand_path("templates", __dir__)

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

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

  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

  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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
po_box-0.1.2 lib/generators/po_box/po_box_generator.rb
po_box-0.1.1 lib/generators/po_box/po_box_generator.rb
po_box-0.1.0 lib/generators/po_box/po_box_generator.rb