Module: ActiveRecordReadOnlyExtension::ClassMethods

Defined in:
app/models/active_record_read_only_extension.rb

Instance Method Summary collapse

Instance Method Details

#console?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/active_record_read_only_extension.rb', line 20

def console?
  defined?(Rails::Console)
end

#rake_task?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/active_record_read_only_extension.rb', line 23

def rake_task?
  File.basename($0) == 'rake'
end

#read_only_mode?Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'app/models/active_record_read_only_extension.rb', line 10

def read_only_mode?
  # Read only mode only applies to the web server, not the console or rake tasks,
  # since they are used for maintenance during read-only mode.
  #
  @@read_only_mode = (read_only_trigger? and not console? and not rake_task?) if not defined?(@@read_only_mode)
  @@read_only_mode
end

#read_only_trigger?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/active_record_read_only_extension.rb', line 17

def read_only_trigger?
  File.exist?(File.join(Rails.root, 'tmp/read_only_mode'))
end