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`.
Constant Summary collapse
- E_PT_AT_REMOVED =
<<-EOS.squish Association Tracking for PaperTrail has been extracted to a separate gem. To use it, please add `paper_trail-association_tracking` to your Gemfile. If you don't use it (most people don't, that's the default) and you set `track_associations = false` somewhere (probably a rails initializer) you can remove that line now. EOS
Instance Attribute Summary collapse
-
#association_reify_error_behaviour ⇒ Object
Returns the value of attribute association_reify_error_behaviour.
-
#has_paper_trail_defaults ⇒ Object
Returns the value of attribute has_paper_trail_defaults.
-
#object_changes_adapter ⇒ Object
Returns the value of attribute object_changes_adapter.
-
#serializer ⇒ Object
Returns the value of attribute serializer.
-
#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=(value) ⇒ Object
In PT 10, the paper_trail-association_tracking gem was changed from a runtime dependency to a development dependency.
-
#track_associations? ⇒ Boolean
own implementation.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
28 29 30 31 32 33 34 35 36 |
# File 'lib/paper_trail/config.rb', line 28 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 @has_paper_trail_defaults = {} end |
Instance Attribute Details
#association_reify_error_behaviour ⇒ Object
Returns the value of attribute association_reify_error_behaviour.
20 21 22 |
# File 'lib/paper_trail/config.rb', line 20 def association_reify_error_behaviour @association_reify_error_behaviour end |
#has_paper_trail_defaults ⇒ Object
Returns the value of attribute has_paper_trail_defaults.
20 21 22 |
# File 'lib/paper_trail/config.rb', line 20 def has_paper_trail_defaults @has_paper_trail_defaults end |
#object_changes_adapter ⇒ Object
Returns the value of attribute object_changes_adapter.
20 21 22 |
# File 'lib/paper_trail/config.rb', line 20 def object_changes_adapter @object_changes_adapter end |
#serializer ⇒ Object
Returns the value of attribute serializer.
20 21 22 |
# File 'lib/paper_trail/config.rb', line 20 def serializer @serializer end |
#version_limit ⇒ Object
Returns the value of attribute version_limit.
20 21 22 |
# File 'lib/paper_trail/config.rb', line 20 def version_limit @version_limit end |
Instance Method Details
#enabled ⇒ Object
Indicates whether PaperTrail is on or off. Default: true.
39 40 41 |
# File 'lib/paper_trail/config.rb', line 39 def enabled @mutex.synchronize { !!@enabled } end |
#enabled=(enable) ⇒ Object
43 44 45 |
# File 'lib/paper_trail/config.rb', line 43 def enabled=(enable) @mutex.synchronize { @enabled = enable } end |
#track_associations=(value) ⇒ Object
In PT 10, the paper_trail-association_tracking gem was changed from a runtime dependency to a development dependency. We raise an error about this for the people who don’t read changelogs.
We raise a generic RuntimeError instead of a specific PT error class because there is no known use case where someone would want to rescue this. If we think of such a use case in the future we can revisit this decision.
own implementation.
58 59 60 61 62 63 64 |
# File 'lib/paper_trail/config.rb', line 58 def track_associations=(value) if value raise E_PT_AT_REMOVED else ::Kernel.warn(E_PT_AT_REMOVED) end end |
#track_associations? ⇒ Boolean
own implementation.
68 69 70 |
# File 'lib/paper_trail/config.rb', line 68 def track_associations? raise E_PT_AT_REMOVED end |