Sha256: 5d348b3a789b0a99a0b466aede14c49c5490a271453796e185dbad919d0b148d
Contents?: true
Size: 802 Bytes
Versions: 12
Compression:
Stored size: 802 Bytes
Contents
class EnvironmentGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) argument :environment, type: :string, required: false, default: nil, desc: "The environment template to copy" def copy_environment_file assert_valid_environment! template("environment.rb", "config/environments/#{file_name}.rb") end private ENVIRONMENTS = %w(development test production) ENVIRONMENTS.each do |env| define_method("#{env}?") { environment == env } end def assert_valid_environment! unless environment.nil? unless ENVIRONMENTS.include?(environment) raise ArgumentError, "Unknown environment: #{environment.inspect}. Valid environments are: #{ENVIRONMENTS.map(&:inspect).join(', ')}" end end end end
Version data entries
12 entries across 12 versions & 1 rubygems