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.
-
#timestamp_field ⇒ Object
Returns the value of attribute timestamp_field.
-
#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.
- #serialized_attributes ⇒ Object
- #serialized_attributes=(_) ⇒ Object
-
#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
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 |
# 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. @timestamp_field = :created_at @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 |
#timestamp_field ⇒ Object
Returns the value of attribute timestamp_field.
9 10 11 |
# File 'lib/paper_trail/config.rb', line 9 def @timestamp_field 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.
56 57 58 |
# File 'lib/paper_trail/config.rb', line 56 def enabled @mutex.synchronize { !!@enabled } end |
#enabled=(enable) ⇒ Object
60 61 62 |
# File 'lib/paper_trail/config.rb', line 60 def enabled=(enable) @mutex.synchronize { @enabled = enable } end |
#serialized_attributes ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/paper_trail/config.rb', line 22 def serialized_attributes ActiveSupport::Deprecation.warn( "PaperTrail.config.serialized_attributes is deprecated without " + "replacement and always returns false." ) false end |
#serialized_attributes=(_) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/paper_trail/config.rb', line 30 def serialized_attributes=(_) ActiveSupport::Deprecation.warn( "PaperTrail.config.serialized_attributes= is deprecated without " + "replacement and no longer has any effect." ) 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`).
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/paper_trail/config.rb', line 41 def track_associations? if @track_associations.nil? ActiveSupport::Deprecation.warn <<-EOS.strip_heredoc.gsub(/\s+/, " ") PaperTrail.track_associations has not been set. As of PaperTrail 5, it defaults to false. Tracking associations is an experimental feature so we recommend setting PaperTrail.config.track_associations = false in your config/initializers/paper_trail.rb EOS false else @track_associations end end |