Class: ActiveRecord::Temporal::ApplicationVersioning::ApplicationVersioned::Revision
- Inherits:
-
Object
- Object
- ActiveRecord::Temporal::ApplicationVersioning::ApplicationVersioned::Revision
- Defined in:
- lib/activerecord/temporal/application_versioning/application_versioned.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize(record, time, **options) ⇒ Revision
constructor
A new instance of Revision.
- #with(attributes) ⇒ Object
Constructor Details
#initialize(record, time, **options) ⇒ Revision
Returns a new instance of Revision.
37 38 39 40 41 |
# File 'lib/activerecord/temporal/application_versioning/application_versioned.rb', line 37 def initialize(record, time, **) @record = record @time = time = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
35 36 37 |
# File 'lib/activerecord/temporal/application_versioning/application_versioned.rb', line 35 def end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
35 36 37 |
# File 'lib/activerecord/temporal/application_versioning/application_versioned.rb', line 35 def record @record end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
35 36 37 |
# File 'lib/activerecord/temporal/application_versioning/application_versioned.rb', line 35 def time @time end |
Instance Method Details
#with(attributes) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/activerecord/temporal/application_versioning/application_versioned.rb', line 43 def with(attributes) new_revision = record.dup new_revision.assign_attributes(attributes) new_revision.id = record.id new_revision.set_time_dimension_start(time) new_revision. = record. record.set_time_dimension_end(time) new_revision.after_initialize_revision(record) if [:save] record.class.transaction do new_revision.save if record.save end end new_revision end |