Module: ActiveRecord::Bitemporal::Bitemporalize::InstanceMethods
- Includes:
- Persistence
- Defined in:
- lib/activerecord-bitemporal.rb
Instance Method Summary
collapse
#_create_record, #_update_row, #destroy, #save, #save!
#bitemporal_option_merge_with_association!, #force_update, #force_update?, #transaction_at, #transaction_datetime, #valid_at, #valid_datetime
Methods included from Optionable
#bitemporal_option, #bitemporal_option_merge!, #with_bitemporal_option
Instance Method Details
#bitemporal_id_key ⇒ Object
94
95
96
|
# File 'lib/activerecord-bitemporal.rb', line 94
def bitemporal_id_key
self.class.bitemporal_id_key
end
|
#bitemporal_ignore_update_columns ⇒ Object
98
99
100
|
# File 'lib/activerecord-bitemporal.rb', line 98
def bitemporal_ignore_update_columns
[]
end
|
#id_in_database ⇒ Object
102
103
104
|
# File 'lib/activerecord-bitemporal.rb', line 102
def id_in_database
swapped_id.presence || super
end
|
#swap_id!(without_clear_changes_information: false) ⇒ Object
79
80
81
82
83
84
|
# File 'lib/activerecord-bitemporal.rb', line 79
def swap_id!(without_clear_changes_information: false)
@_swapped_id_previously_was = nil
@_swapped_id = self.id
self.id = self.send(bitemporal_id_key)
clear_attribute_changes([:id]) unless without_clear_changes_information
end
|
#swapped_id ⇒ Object
86
87
88
|
# File 'lib/activerecord-bitemporal.rb', line 86
def swapped_id
@_swapped_id || self.id
end
|
#swapped_id_previously_was ⇒ Object
90
91
92
|
# File 'lib/activerecord-bitemporal.rb', line 90
def swapped_id_previously_was
@_swapped_id_previously_was
end
|
#transaction_from_cannot_be_greater_equal_than_transaction_to ⇒ Object
112
113
114
115
116
|
# File 'lib/activerecord-bitemporal.rb', line 112
def transaction_from_cannot_be_greater_equal_than_transaction_to
if transaction_from && transaction_to && transaction_from >= transaction_to
errors.add(:transaction_from, "can't be greater equal than transaction_to")
end
end
|
#valid_from_cannot_be_greater_equal_than_valid_to ⇒ Object
106
107
108
109
110
|
# File 'lib/activerecord-bitemporal.rb', line 106
def valid_from_cannot_be_greater_equal_than_valid_to
if valid_from && valid_to && valid_from >= valid_to
errors.add(:valid_from, "can't be greater equal than valid_to")
end
end
|