Class: PaperTrail::Config
- Inherits:
-
Object
- Object
- PaperTrail::Config
- 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
-
#serializer ⇒ Object
Returns the value of attribute serializer.
-
#track_associations ⇒ Object
writeonly
Sets the attribute track_associations.
-
#version_limit ⇒ Object
Returns the value of attribute version_limit.
Instance Method Summary collapse
-
#enabled ⇒ Object
Indicates whether PaperTrail is on or off.
- #enabled=(enable) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#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`).
Constructor Details
#initialize ⇒ Config
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
#serializer ⇒ Object
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_limit ⇒ Object
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
#enabled ⇒ Object
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+/, " ") |