method
user_supplied_options
v6.0.0 -
Show latest stable
-
0 notes -
Class: ServerCommand
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
user_supplied_options()
private
Hide source
# File railties/lib/rails/commands/server/server_command.rb, line 175 def user_supplied_options @user_supplied_options ||= begin # Convert incoming options array to a hash of flags # ["-p3001", "-C", "--binding", "127.0.0.1"] # => {"-p"=>true, "-C"=>true, "--binding"=>true} user_flag = {} @original_options.each do |command| if command.to_s.start_with?("--") option = command.split("=")[0] user_flag[option] = true elsif command =~ /\A(-.)/ user_flag[Regexp.last_match[0]] = true end end # Collect all options that the user has explicitly defined so we can # differentiate them from defaults user_supplied_options = [] self.class.class_options.select do |key, option| if option.aliases.any? { |name| user_flag[name] } || user_flag["--#{option.name}"] name = option.name.to_sym case name when :port name = :Port when :binding name = :Host when :dev_caching name = :caching when :daemonize name = :daemon end user_supplied_options << name end end user_supplied_options << :Host if ENV["HOST"] || ENV["BINDING"] user_supplied_options << :Port if ENV["PORT"] user_supplied_options.uniq end end