Class: PaperTrail::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/paper_trail/config.rb

Overview

Global configuration affecting all threads. Some thread-specific configuration can be found in paper_trail.rb, others in controller.rb.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig



12
13
14
15
16
17
18
19
# File 'lib/paper_trail/config.rb', line 12

def initialize
  # Variables which affect all threads, whose access is synchronized.
  @mutex = Mutex.new
  @enabled = true

  # Variables which affect all threads, whose access is *not* synchronized.
  @serializer = PaperTrail::Serializers::YAML
end

Instance Attribute Details

#serializerObject

Returns the value of attribute serializer.



9
10
11
# File 'lib/paper_trail/config.rb', line 9

def serializer
  @serializer
end

#track_associations=(value) ⇒ Object (writeonly)

Sets the attribute track_associations



10
11
12
# File 'lib/paper_trail/config.rb', line 10

def track_associations=(value)
  @track_associations = value
end

#version_limitObject

Returns the value of attribute version_limit.



9
10
11
# File 'lib/paper_trail/config.rb', line 9

def version_limit
  @version_limit
end

Instance Method Details

#enabledObject

Indicates whether PaperTrail is on or off. Default: true.



40
41
42
# File 'lib/paper_trail/config.rb', line 40

def enabled
  @mutex.synchronize { !!@enabled }
end

#enabled=(enable) ⇒ Object



44
45
46
# File 'lib/paper_trail/config.rb', line 44

def enabled=(enable)
  @mutex.synchronize { @enabled = enable }
end

#track_associations?Boolean

Previously, we checked PaperTrail::VersionAssociation.table_exists? here, but that proved to be problematic in situations when the database connection had not been established, or when the database does not exist yet (as with ‘rake db:create`).



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/paper_trail/config.rb', line 25

def track_associations?
  if @track_associations.nil?
    ActiveSupport::Deprecation.warn "      PaperTrail.config.track_associations has not been set. As of PaperTrail 5, it\n      defaults to false. Tracking associations is an experimental feature so\n      we recommend setting PaperTrail.config.track_associations = false in\n      your config/initializers/paper_trail.rb\n    EOS\n    false\n  else\n    @track_associations\n  end\nend\n".strip_heredoc.gsub(/\s+/, " ")