Sha256: 4067e81836f5a5f8bee1e757a5e7cbd9d4c4986e69d572186d3b3e18be6d9e57
Contents?: true
Size: 919 Bytes
Versions: 4
Compression:
Stored size: 919 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 create_environment_file assert_valid_environment! template('environment.rb', File.join('config/environments', class_path, "#{file_name}.rb")) end private ENVIRONMENTS = %w(development test production).freeze 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 options: #{ENVIRONMENTS.map(&:inspect).join(', ')}" ].join(' ') end end end end
Version data entries
4 entries across 4 versions & 1 rubygems