Class: Safeconsole::Console

Inherits:
Object
  • Object
show all
Extended by:
Commands
Includes:
Messages, Singleton
Defined in:
lib/safeconsole/console.rb

Class Attribute Summary collapse

Class Method Summary collapse

Methods included from Commands

commands, commit, done, nevermind, refresh, stats

Methods included from Messages

app_name, commands, commit, done, included, invalid_query, method_missing, nevermind, refresh, respond_to_missing?, session_expired, session_start, session_stats, transaction_start, unsafe_env, welcome

Class Attribute Details

.__console_commitObject

Returns the value of attribute __console_commit.



12
13
14
# File 'lib/safeconsole/console.rb', line 12

def __console_commit
  @__console_commit
end

.__console_doneObject

Returns the value of attribute __console_done.



12
13
14
# File 'lib/safeconsole/console.rb', line 12

def __console_done
  @__console_done
end

Class Method Details

.done!Object



40
41
42
43
# File 'lib/safeconsole/console.rb', line 40

def done!
  @__console_done = true
  @__exit_safeconsole = true
end

.done?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/safeconsole/console.rb', line 45

def done?
  @__console_done
end

.runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/safeconsole/console.rb', line 14

def run
  print_message(:welcome)
  print_message(:commands)

  SessionWatcher.watch_session! if Safeconsole.watch_session?

  print_message(:session_start)

  loop do
    @__console_done = false
    @__console_commit = false
    print_message(:transaction_start)

    ActiveRecord::Base.transaction do
      binding.pry quiet: true, prompt_name: "safeconsole" # standard:disable Lint/Debugger

      raise ActiveRecord::Rollback unless @__console_commit
    end

    break print_message(:done) if @__console_done

    print_message(:refresh)
    sleep 0.5
  end
end