Class: Flog::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/flog/status.rb

Overview

Status returns checke result of switch files

Constant Summary collapse

SWITCH_FILE_NAME =
'no-flog.txt'
SQL_SWITCH_FILE_NAME =
'no-flog-sql.txt'
PARAMS_SWITCH_FILE_NAME =
'no-flog-params.txt'

Class Method Summary collapse

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/flog/status.rb', line 12

def enabled?
  !switch_file_exists?(SWITCH_FILE_NAME)
rescue StandardError
  true
end

.params_formattable?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/flog/status.rb', line 24

def params_formattable?
  enabled? && !switch_file_exists?(PARAMS_SWITCH_FILE_NAME)
rescue StandardError
  true
end

.sql_formattable?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/flog/status.rb', line 18

def sql_formattable?
  enabled? && !switch_file_exists?(SQL_SWITCH_FILE_NAME)
rescue StandardError
  true
end

.switch_file_base_pathObject



30
31
32
33
34
35
36
# File 'lib/flog/status.rb', line 30

def switch_file_base_path
  if Rails.root&.exist?
    Rails.root
  else
    Pathname.new(File.expand_path(File.dirname(__FILE__) + '../../'))
  end
end

.switch_file_dir_pathObject



38
39
40
# File 'lib/flog/status.rb', line 38

def switch_file_dir_path
  switch_file_base_path.join('tmp')
end