Class: Outbox::Generators::TransportGenerator

Inherits:
NamedBase
  • Object
show all
Defined in:
lib/generators/outbox/transport/transport_generator.rb

Constant Summary

Constants included from Helpers::Values

Helpers::Values::VALUES_PATH

Constants included from Helpers::Paas

Helpers::Paas::APP_MANIFEST_PATH

Constants included from Helpers::Initializer

Helpers::Initializer::OUTBOX_INITIALIZER_PATH

Constants included from Helpers::Config

Helpers::Config::CONFIG_PATH

Instance Method Summary collapse

Methods included from Helpers::Items

#item_path, #namespaced_item_class_name

Instance Method Details

#check!Object



24
25
26
# File 'lib/generators/outbox/transport/transport_generator.rb', line 24

def check!
  check_config!
end

#check_item_exists!Object

Raises:

  • (Rails::Generators::Error)


28
29
30
31
32
33
34
# File 'lib/generators/outbox/transport/transport_generator.rb', line 28

def check_item_exists!
  return if item_exists?

  raise Rails::Generators::Error, "Item `#{item_name}` does not exist in the `#{options[:kind]}_items` " \
                                  "section of #{CONFIG_PATH}. You may insert this item by running " \
                                  "`bin/rails g outbox:item #{item_name} --kind #{options[:kind]}`"
end

#check_name!Object

Raises:

  • (Rails::Generators::Error)


18
19
20
21
22
# File 'lib/generators/outbox/transport/transport_generator.rb', line 18

def check_name!
  return if options[:kind].in?(%w[inbox outbox])

  raise Rails::Generators::Error, "Unknown transport type. Should be inbox or outbox"
end

#insert_transportObject



36
37
38
39
# File 'lib/generators/outbox/transport/transport_generator.rb', line 36

def insert_transport
  data = optimize_indentation(template, 6)
  insert_into_file CONFIG_PATH, data, after: "#{item_name.underscore}:\n", force: true
end