Module: Hoardable
- Defined in:
- lib/hoardable/engine.rb,
lib/hoardable/error.rb,
lib/hoardable/model.rb,
lib/hoardable/scopes.rb,
lib/hoardable/has_one.rb,
lib/hoardable/version.rb,
lib/hoardable/has_many.rb,
lib/hoardable/arel_crud.rb,
lib/hoardable/rich_text.rb,
lib/hoardable/belongs_to.rb,
lib/hoardable/associations.rb,
lib/hoardable/source_model.rb,
lib/hoardable/arel_visitors.rb,
lib/hoardable/has_rich_text.rb,
lib/hoardable/schema_dumper.rb,
lib/hoardable/version_model.rb,
lib/hoardable/finder_methods.rb,
lib/hoardable/database_client.rb,
lib/hoardable/schema_statements.rb,
lib/hoardable/encrypted_rich_text.rb,
lib/generators/hoardable/install_generator.rb,
lib/generators/hoardable/migration_generator.rb
Overview
An ActiveRecord
extension for keeping versions of records in uni-temporal inherited tables.
Defined Under Namespace
Modules: ArelCrud, ArelVisitors, Associations, FinderMethods, Model, Scopes, SourceModel, VersionModel Classes: CreatedAtColumnMissingError, EncryptedRichText, Engine, Error, InstallGenerator, InvalidTemporalUpperBoundError, MigrationGenerator, RichText, UpdatedAtColumnMissingError
Constant Summary collapse
- REGISTRY =
Set.new
- DATA_KEYS =
Symbols for use with setting contextual data, when creating versions. See README for more.
i[ whodunit].freeze
- CONFIG_KEYS =
i[enabled version_updates save_trash].freeze
- VERSION =
"0.19.2"
Class Method Summary collapse
-
.at(datetime) ⇒ Object
Allows performing a query for record states at a certain time.
-
.travel_to(datetime) ⇒ Object
Allows calling code to set the upper bound for the temporal range for recorded audits.
-
.with(hash) ⇒ Object
This is a general use method for setting Contextual Data or Configuration around a block.
Class Method Details
.at(datetime) ⇒ Object
Allows performing a query for record states at a certain time. Returned SourceModel instances within the block may be SourceModel or VersionModel records.
86 87 88 89 90 91 92 |
# File 'lib/hoardable/engine.rb', line 86 def at(datetime) thread = Thread.current thread[:hoardable_at] = datetime yield ensure thread[:hoardable_at] = nil end |
.travel_to(datetime) ⇒ Object
Allows calling code to set the upper bound for the temporal range for recorded audits.
97 98 99 100 101 102 103 |
# File 'lib/hoardable/engine.rb', line 97 def travel_to(datetime) thread = Thread.current thread[:hoardable_travel_to] = datetime yield ensure thread[:hoardable_travel_to] = nil end |
.with(hash) ⇒ Object
This is a general use method for setting Contextual Data or Configuration around a block.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/hoardable/engine.rb', line 62 def with(hash) thread = Thread.current current_thread_config = thread[:hoardable_config] current_thread_context = thread[:hoardable_context] thread[:hoardable_config] = hoardable_config.merge(hash.slice(*CONFIG_KEYS)) thread[:hoardable_context] = hoardable_context.merge(hash.slice(*DATA_KEYS)) yield ensure thread[:hoardable_config] = current_thread_config thread[:hoardable_context] = current_thread_context end |