Module: SaferRailsConsole::Patches::Boot::SandboxFlag::Rails::Console4

Defined in:
lib/safer_rails_console/patches/boot/sandbox_flag.rb

Instance Method Summary collapse

Instance Method Details

#parse_arguments(arguments) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/safer_rails_console/patches/boot/sandbox_flag.rb', line 27

def parse_arguments(arguments)
  options = {}

  OptionParser.new do |opt|
    ::SaferRailsConsole::Patches::Boot::SandboxFlag.console_options(opt, options)
    opt.on('--debugger', 'Enable the debugger.') { |v| options[:debugger] = v }
    opt.parse!(arguments)
  end

  if arguments.first && arguments.first[0] != '-'
    env = arguments.first
    options[:environment] = if available_environments.include? env
                              env
                            else
                              %w(production development test).detect { |e| e =~ /^#{env}/ } || env
                            end
  end

  options
end