Module: Rails::Command::EnvironmentArgument
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::ActiveSupport::Concern
|
|
Defined in: | railties/lib/rails/command/environment_argument.rb |
Class Method Summary
::ActiveSupport::Concern
- Extended
class_methods | Define class methods from given block. |
included | Evaluate given block in context of base class, so that you can write class macros here. |
prepended | Evaluate given block in context of base class, so that you can write class macros here. |
append_features, prepend_features |
Instance Attribute Summary
- #environment rw private
- #environment=(environment) rw private
- #environment_specified? ⇒ Boolean readonly private
Instance Method Summary
- #initialize
- #available_environments private
- #expand_environment_name(name) private
- #require_application! private
DSL Calls
included
[ GitHub ]11 12 13 14
# File 'railties/lib/rails/command/environment_argument.rb', line 11
included do class_option :environment, aliases: "-e", type: :string, desc: "The environment to run `#{self.command_name}` in (e.g. test / development / production)." end
Instance Attribute Details
#environment (rw, private)
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 34
def environment @environment ||= [:environment] end
#environment=(environment) (rw, private)
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 38
def environment=(environment) @environment = environment end
#environment_specified? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'railties/lib/rails/command/environment_argument.rb', line 42
def environment_specified? @environment_specified end
Instance Method Details
#available_environments (private)
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 46
def available_environments @available_environments ||= Dir["config/environments/*.rb"].map { |filename| File.basename(filename, ".*") } end
#expand_environment_name(name) (private)
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 51
def (name) %w[production development test].find { |full_name| full_name.start_with?(name) } || name end
#initialize
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 16
def initialize(...) super @environment_specified = [:environment].present? if !@environment_specified self. = .merge(environment: Rails::Command.environment) elsif !available_environments.include?( [:environment]) self. = .merge(environment: ( [:environment])) end end
#require_application! (private)
[ GitHub ]# File 'railties/lib/rails/command/environment_argument.rb', line 29
def require_application! ENV["RAILS_ENV"] = environment super end